35 lines
1.1 KiB
Smalltalk
35 lines
1.1 KiB
Smalltalk
accessing
|
|
numberOfURLsForLoadingTweets: number
|
|
|
|
| collectionURLs count asURLs urlAndTweets |
|
|
number = 1 ifTrue: [ ^ self ].
|
|
|
|
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 ]).
|
|
count := count+1 ].
|
|
|
|
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
|
|
|
urlAndTweets at: 'urls' put: asURLs.
|
|
|
|
^ urlAndTweets. |