Socialmetrica/Socialmetrica.package/Tweet.class/instance/metricsFromNitterHtml..st

24 lines
1.2 KiB
Smalltalk

accessing
metricsFromNitterHtml: xmlItem
"TO DO: Metrics scrapping are not consistent.
Most times they store numbers, but sometimes, retweets store a userName"
self metrics
at: 'comment'
put: (((xmlItem xpath: '//div[@class="tweet-stats"]//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'comment' ])
stringValue trimmed copyReplaceAll: ',' with: '');
at: 'retweet'
put: (((xmlItem xpath: '//div[@class="tweet-stats"]//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'retweet' ])
stringValue trimmed copyReplaceAll: ',' with: '');
at: 'quote'
put: (((xmlItem xpath: '//div[@class="tweet-stats"]//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'quote' ])
stringValue trimmed copyReplaceAll: ',' with: '');
at: 'heart'
put: (((xmlItem xpath: '//div[@class="tweet-stats"]//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'heart' ])
stringValue trimmed copyReplaceAll: ',' with: '').
self metadata
at: 'pinned'
put: (xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed = 'Pinned Tweet'