2022-04-06 00:29:34 +00:00
|
|
|
accessing
|
|
|
|
numberOfURLsForLoadingTweets: number
|
|
|
|
|
2022-04-07 19:17:17 +00:00
|
|
|
| collectionURLs count asURLs urlAndTweets |
|
|
|
|
number = 1 ifTrue: [ ^ self ].
|
2022-04-11 17:11:10 +00:00
|
|
|
|
2022-04-07 19:17:17 +00:00
|
|
|
urlAndTweets := OrderedDictionary new.
|
2022-04-11 17:11:10 +00:00
|
|
|
collectionURLs := { self userNameLink } asOrderedCollection.
|
|
|
|
|
|
|
|
urlAndTweets at: 'tweets' put: self lastTweetsFromHtml.
|
|
|
|
|
2022-04-07 19:17:17 +00:00
|
|
|
count := 1.
|
2022-04-11 17:11:10 +00:00
|
|
|
number - count timesRepeat: [
|
|
|
|
| tempDoc docTree urlString |
|
|
|
|
tempDoc := XMLHTMLParser parse:
|
|
|
|
(collectionURLs at: count) asUrl retrieveContents.
|
|
|
|
|
|
|
|
urlString := self userNameLink
|
|
|
|
,
|
|
|
|
((tempDoc xPath: '//a[.="Load more"]') @ 'href')
|
|
|
|
stringValue.
|
2022-04-07 19:17:17 +00:00
|
|
|
docTree := XMLHTMLParser parse: urlString asUrl retrieveContents.
|
2022-04-11 17:11:10 +00:00
|
|
|
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 ].
|
|
|
|
|
2022-04-06 00:29:34 +00:00
|
|
|
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
2022-04-11 17:11:10 +00:00
|
|
|
|
2022-04-07 19:17:17 +00:00
|
|
|
urlAndTweets at: 'urls' put: asURLs.
|
2022-04-11 17:11:10 +00:00
|
|
|
|
|
|
|
^ urlAndTweets
|