Improving tweet parsing from nitter timeline item.
This commit is contained in:
parent
e8f9e1ddd9
commit
d9af46ec37
@ -1,12 +1,28 @@
|
|||||||
accessing
|
accessing
|
||||||
fromNitterTimelineItem: xmlItem
|
fromNitterTimelineItem: xmlItem
|
||||||
| author authorAndId |
|
| author authorAndId metricsTemp timeTemp |
|
||||||
authorAndId := (((xmlItem xpath: '//a[@class="tweet-link"]')
|
authorAndId := (((xmlItem xpath: '//a[@class="tweet-link"]')
|
||||||
asString splitOn: 'href="' ) second splitOn: '/') reject: [ :i | i isEmpty or: [i = '>)']].
|
asString splitOn: 'href="' ) second splitOn: '/') reject: [ :i | i isEmpty or: [i = '>)']].
|
||||||
author := authorAndId first.
|
author := authorAndId first.
|
||||||
user := NitterUser new
|
user := NitterUser new
|
||||||
userName: author .
|
userName: author .
|
||||||
"created := (xmlItem xpath: 'pubDate') stringValue.
|
|
||||||
text := (xmlItem xpath: 'description') stringValue."
|
timeTemp := (((xmlItem xpath: '//span[@class="tweet-date"]')asString splitOn: 'title="') second splitOn: '">')first.
|
||||||
|
timeTemp := ((timeTemp copyReplaceAll: ' · ' with: ' ') copyReplaceAll: 'UTC' with: '+00:00') asDateAndTime.
|
||||||
|
created := timeTemp.
|
||||||
|
|
||||||
|
text := (xmlItem xpath: '//div[@class="tweet-content media-body"]')stringValue.
|
||||||
id := authorAndId last copyReplaceAll: '#m"' with: ''.
|
id := authorAndId last copyReplaceAll: '#m"' with: ''.
|
||||||
authorId := self user id.
|
authorId := self user id.
|
||||||
|
|
||||||
|
metricsTemp := Dictionary new .
|
||||||
|
metricsTemp
|
||||||
|
at: 'comment'
|
||||||
|
put: (xmlItem xpath: '//div[@class="icon-container"]') second stringValue trimmed;
|
||||||
|
at: 'retweet'
|
||||||
|
put: (xmlItem xpath: '//div[@class="icon-container"]') third stringValue trimmed;
|
||||||
|
at: 'quote'
|
||||||
|
put: (xmlItem xpath: '//div[@class="icon-container"]') fourth stringValue trimmed;
|
||||||
|
at: 'heart'
|
||||||
|
put: (xmlItem xpath: '//div[@class="icon-container"]') fifth stringValue trimmed.
|
||||||
|
metrics := metricsTemp.
|
Loading…
Reference in New Issue
Block a user