Minor fix in quotes scraping.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-04-18 22:14:17 -05:00
parent 2383ea4459
commit c2078d032f
1 changed files with 12 additions and 7 deletions

View File

@ -1,14 +1,19 @@
accessing
metadataFromNitterHtml: xmlItem
| quoteSubtree |
self metadata
at: 'pinned'
put: (xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed
= 'Pinned Tweet';
at: 'replie to' put: (xmlItem xpath:
'//div[@class="tweet-body"]//div[@class="replying-to"]')
stringValue trimmed;
at: 'quote' put: (((xmlItem xpath:
'//div[@class="tweet-body"]//div[@class="quote quote-big"]//a[@class="quote-link"]')
postCopy asString splitOn: 'href="/') second removeSuffix:
'"/>)')
at: 'replie to'
put: (xmlItem xpath: '//div[@class="tweet-body"]//div[@class="replying-to"]') stringValue trimmed.
quoteSubtree := xmlItem xpath: '//div[@class="tweet-body"]//div[@class="quote quote-big"]//a[@class="quote-link"]'.
quoteSubtree set isEmpty
ifTrue: [ self metadata at: 'quote' put: '' ]
ifFalse: [
self metadata
at: 'quote'
put: ((quoteSubtree postCopy asString splitOn: 'href="/')
second removeSuffix: '"/>)')
]