Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need to monitor tweets from several users.

So I'd like to grab all of the users' rss feeds and then sort the data by time of post.

Here is what I whipped up to grab all the data:
Copy      Help
str s=
s.findreplace("," "[]")
for _i 0 numlines(s)
,_s.getl(s _i)
,IntGetFile _s str'Twitter
,for int'i 0 numlines(Twitter)
,,str Line.getl(Twitter i)
,,if(matchw(Line "*href=''*.rss*"))
,,,str Title=Line
,,,str mSearch="title=''"
,,,int Mark=find(Title mSearch 0 1)
,,,Title.remove(0 Mark+mSearch.len)
,,,Mark=find(Title "'' type=''")
,,,Line.findreplace("    <link rel=''alternate'' href=''")
,,,int RSS=find(Line ".rss")
,,,IntGetFile Line str'rss
,,,;mes rss
,,,mkdir "$desktop$\twitter\"

I'm thinking that changing all of the dates to a int (i.e. "Fri, 14 May 2010 23:11:26 +0000" = 201005231126)
Then putting all of the data into a CSV variable and then sort by the time stamp.

Jimmy Vig
To convert such date string to number, at first need to make standard format "mm/dd/yyyy hh:mmConfuseds", then assign to a DATE variable.
Function cTwitterDate
Copy      Help
function str&TwitterDate
ARRAY(str) a
int i=findrx(TwitterDate "(\w{3}), (\d{2}) (\w{3}) (\d{4}) (\d{2}:\d{2}:\d{2})" 0 0 a)
str sDate=F"{a[3]}-{a[2]}-{a[4]} {a[5]}"
DATE dDate=sDate
sDate.timeformat("{yyyy}{MM}{dd}{HH}{mm}{ss}" dDate)


Function TwitterParse
Copy      Help
function str&Data

IXml x=CreateXml
ARRAY(IXmlNode) a
x.Path("rss/channel/item" a)
int i
for i 0 a.len
,IXmlNode n=a[i].FirstChild
,for _i 0 6
,,if(!n) break
,,sel _i
,,,case 2
,,,str TimeStamp=n.Value
,,,cTwitterDate TimeStamp
,,,case 0
,,,str Title=n.Value
,,,Title.findreplace("[]" " ")
,str Tweet=F"({TimeStamp}) {Title}"

Yep. Pretty Much from here it's pretty simple. I ended up just putting the date at that start of a string and then populated an array. Used sort(1). Got exactly what I wanted.

Forum Jump:

Users browsing this thread: 1 Guest(s)