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-06 00:29:34 +00:00
|
|
|
|
2022-04-07 19:17:17 +00:00
|
|
|
urlAndTweets := OrderedDictionary new.
|
|
|
|
collectionURLs := { self userNameLink .}asOrderedCollection.
|
|
|
|
|
|
|
|
urlAndTweets
|
|
|
|
at: 'tweets'
|
|
|
|
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).
|
|
|
|
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 ]).
|
2022-04-06 00:29:34 +00:00
|
|
|
count := count+1 ].
|
2022-04-07 19:17:17 +00:00
|
|
|
|
2022-04-06 00:29:34 +00:00
|
|
|
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
2022-04-07 19:17:17 +00:00
|
|
|
|
|
|
|
urlAndTweets at: 'urls' put: asURLs.
|
|
|
|
|
|
|
|
^ urlAndTweets.
|