Improving modularization with the new NitterUser object.
This commit is contained in:
parent
15db771f80
commit
321ddc8e71
0
Datanalitica.package/NitterUser.class/README.md
Normal file
0
Datanalitica.package/NitterUser.class/README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
accessing
|
||||||
|
createdAt
|
||||||
|
^ createdAt ifNil: [| joinDateString |
|
||||||
|
joinDateString := ((self documentTree xpath: '//div[@class="profile-joindate"]/span/@title') stringValue).
|
||||||
|
createdAt := (ZTimestampFormat fromString:'4:05 PM - 03 Feb 2001') parse: joinDateString.
|
||||||
|
]
|
@ -0,0 +1,3 @@
|
|||||||
|
accessing
|
||||||
|
description
|
||||||
|
^ description ifNil: [description := (self documentTree xpath: '//div[@class="profile-bio"]') stringValue]
|
@ -0,0 +1,3 @@
|
|||||||
|
operation
|
||||||
|
documentTree
|
||||||
|
^ (XMLDOMParser on: self userNameLink asUrl retrieveContents) parseDocument
|
3
Datanalitica.package/NitterUser.class/instance/name.st
Normal file
3
Datanalitica.package/NitterUser.class/instance/name.st
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
accessing
|
||||||
|
name
|
||||||
|
^ name ifNil: [ name := ((self rssFeed requiredItems title) splitOn: '/') first ]
|
@ -0,0 +1,3 @@
|
|||||||
|
accessing
|
||||||
|
profileImageUrl
|
||||||
|
^ profileImageUrl ifNil: [ (self rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/' ]
|
@ -0,0 +1,4 @@
|
|||||||
|
accessing
|
||||||
|
rssFeed
|
||||||
|
|
||||||
|
^ RSSTools createRSSFeedFor: self userNameLink , '/rss'
|
@ -0,0 +1,3 @@
|
|||||||
|
accessing
|
||||||
|
userName: userNameString
|
||||||
|
userName := userNameString.
|
@ -0,0 +1,4 @@
|
|||||||
|
accessing
|
||||||
|
userNameLink
|
||||||
|
|
||||||
|
^ 'https://nitter.net/' , self userName
|
11
Datanalitica.package/NitterUser.class/properties.json
Normal file
11
Datanalitica.package/NitterUser.class/properties.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"commentStamp" : "",
|
||||||
|
"super" : "TwitterUser",
|
||||||
|
"category" : "Datanalitica-Datanalitica",
|
||||||
|
"classinstvars" : [ ],
|
||||||
|
"pools" : [ ],
|
||||||
|
"classvars" : [ ],
|
||||||
|
"instvars" : [ ],
|
||||||
|
"name" : "NitterUser",
|
||||||
|
"type" : "normal"
|
||||||
|
}
|
@ -1,3 +1,3 @@
|
|||||||
accessing
|
accessing
|
||||||
createdAtShorted
|
createdAtShorted
|
||||||
^ self createdAt asString copyFrom: 1 to: 7
|
^ self createdAt asString copyFrom: 1 to: 10
|
@ -1,14 +1,10 @@
|
|||||||
accessing
|
accessing
|
||||||
fromNitterProfile: userNameString
|
fromNitterProfile: userNameString
|
||||||
| nitterProfileLink rssFeed title nitterDocTree joinDateString |
|
| nitterUser joinDateString |
|
||||||
nitterProfileLink := 'https://nitter.net/', userNameString.
|
nitterUser := NitterUser new userName: userNameString.
|
||||||
rssFeed := RSSTools createRSSFeedFor: nitterProfileLink, '/rss'.
|
name := nitterUser name.
|
||||||
title := rssFeed requiredItems title.
|
userName := NitterUser new userName: userNameString.
|
||||||
name := (title splitOn: '/') first trimmed.
|
"((title splitOn: '/') second trimmed) allButFirst." "<--This should go to a test."
|
||||||
"Tecnically we could just do 'userName' = 'userNameString'. But we want to capture also how it is expressed in the RSS."
|
profileImageUrl := nitterUser profileImageUrl.
|
||||||
userName := ((title splitOn: '/') second trimmed) allButFirst. "Taking out the '@' sign."
|
description := nitterUser description.
|
||||||
profileImageUrl := (rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/'.
|
createdAt := nitterUser createdAt.
|
||||||
nitterDocTree := (XMLDOMParser on: nitterProfileLink asUrl retrieveContents) parseDocument.
|
|
||||||
description := (nitterDocTree xpath: '//div[@class="profile-bio"]') stringValue.
|
|
||||||
joinDateString := ((nitterDocTree xpath: '//div[@class="profile-joindate"]/span/@title') stringValue).
|
|
||||||
createdAt := (ZTimestampFormat fromString:'4:05 PM - 03 Feb 2001') parse: joinDateString.
|
|
@ -14,7 +14,8 @@
|
|||||||
"metrics",
|
"metrics",
|
||||||
"tweets",
|
"tweets",
|
||||||
"createdAt",
|
"createdAt",
|
||||||
"groups"
|
"groups",
|
||||||
|
"url"
|
||||||
],
|
],
|
||||||
"name" : "TwitterUser",
|
"name" : "TwitterUser",
|
||||||
"type" : "normal"
|
"type" : "normal"
|
||||||
|
Loading…
Reference in New Issue
Block a user