Improving urls for load more tweets and removing unnecessary method. ref 5b169c4ebf
This commit is contained in:
parent
610c8e4ca1
commit
b198bde247
@ -1,5 +0,0 @@
|
|||||||
accessing
|
|
||||||
defaultConfig
|
|
||||||
|
|
||||||
self config: { 'folder' -> (FileLocator userData / 'Socialmetrica' / self userName) } asDictionary.
|
|
||||||
^ self config
|
|
@ -1,18 +1,35 @@
|
|||||||
accessing
|
accessing
|
||||||
numberOfURLsForLoadingTweets: number
|
numberOfURLsForLoadingTweets: number
|
||||||
|
|
||||||
| collectionURLs count asURLs |
|
| collectionURLs count asURLs urlAndTweets |
|
||||||
collectionURLs := {
|
number = 1 ifTrue: [ ^ self ].
|
||||||
self userNameLink .
|
|
||||||
(self userNameLink, ((self documentTree xPath: '//a[.="Load more"]') @ 'href') stringValue) .} asOrderedCollection.
|
|
||||||
|
|
||||||
number <= 2 ifTrue: [ ^ collectionURLs ].
|
urlAndTweets := OrderedDictionary new.
|
||||||
count := 2.
|
collectionURLs := { self userNameLink .}asOrderedCollection.
|
||||||
(number-count) timesRepeat: [ | tempDoc |
|
|
||||||
tempDoc := XMLHTMLParser parse: (collectionURLs at: count) asUrl retrieveContents.
|
urlAndTweets
|
||||||
collectionURLs
|
at: 'tweets'
|
||||||
add: (self userNameLink,
|
put: ((self documentTree xpath: '//div[@class="timeline-item "]')asOrderedCollection collect: [ :xmlElement | xmlElement postCopy]).
|
||||||
|
|
||||||
|
count := 1.
|
||||||
|
(number-count) timesRepeat: [ | tempDoc docTree urlString |
|
||||||
|
tempDoc := XMLHTMLParser parse:
|
||||||
|
(collectionURLs at: count) asUrl retrieveContents.
|
||||||
|
|
||||||
|
urlString := (self userNameLink,
|
||||||
((tempDoc xPath: '//a[.="Load more"]') @ 'href') stringValue).
|
((tempDoc xPath: '//a[.="Load more"]') @ 'href') stringValue).
|
||||||
|
docTree := XMLHTMLParser parse: urlString asUrl retrieveContents.
|
||||||
|
collectionURLs
|
||||||
|
add: urlString.
|
||||||
|
|
||||||
|
urlAndTweets
|
||||||
|
at: 'tweets-', (urlString splitOn: 'cursor=') second
|
||||||
|
put: ((docTree xpath: '//div[@class="timeline-item "]')asOrderedCollection
|
||||||
|
collect: [ :xmlElement | xmlElement postCopy ]).
|
||||||
count := count+1 ].
|
count := count+1 ].
|
||||||
|
|
||||||
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
||||||
^ asURLs.
|
|
||||||
|
urlAndTweets at: 'urls' put: asURLs.
|
||||||
|
|
||||||
|
^ urlAndTweets.
|
@ -0,0 +1,12 @@
|
|||||||
|
accessing
|
||||||
|
fromNitterTimelineItem: xmlItem
|
||||||
|
| author authorAndId |
|
||||||
|
authorAndId := (((xmlItem xpath: '//a[@class="tweet-link"]')
|
||||||
|
asString splitOn: 'href="' ) second splitOn: '/') reject: [ :i | i isEmpty or: [i = '>)']].
|
||||||
|
author := authorAndId first.
|
||||||
|
user := NitterUser new
|
||||||
|
userName: author .
|
||||||
|
"created := (xmlItem xpath: 'pubDate') stringValue.
|
||||||
|
text := (xmlItem xpath: 'description') stringValue."
|
||||||
|
id := authorAndId last copyReplaceAll: '#m"' with: ''.
|
||||||
|
authorId := self user id.
|
Loading…
Reference in New Issue
Block a user