def opmlOut(tw, tag): fo = newt.openTimestampedFile("opml", 'hashtag-' + tag + '.xml', False) newt.writeOPMLHeadopenBody(fo) newt.openOPMLoutline(fo, tag) for i in tw: newt.handleOPMLitem(fo, tw[i].url) newt.closeOPMLoutline(fo) newt.closeOPMLbody(fo) fo.close()
except: extra=-1 try: sampleSize=int(sys.argv[4]) except: sampleSize='all' #---------------------------------------------------------------- tw={} if typ=="followers": tw=newt.getTwitterFollowersDetailsByIDs(api,user,sampleSize) else: tw=newt.getTwitterFriendsDetailsByIDs(api,user,sampleSize) f=newt.openTimestampedFile(user+'/'+typ,'sample'+str(sampleSize)+'tweeps.txt') for tweep in tw: f.write(str(tweep)+'\n') f.close() report("List members:") for i in tw: report(tw[i].screen_name) ''' report("List members:") for i in tw: report(tw[i].screen_name) ''' #newt.gephiOutputFile(api,user+'/'+typ, tw,'outerfriends') newt.gephiOutputFile(api,user+'/'+typ, tw)
opml = False api = newt.getTwitterAPI() tweeters = {} tags = {} print 'Looking for twitterers and tags in context of hashtag (excluding oldstyle RT messages)', tag tweeters, tags, tweets = newt.twSearchHashtag(tweeters, tags, num, tag, exclRT=True) fo = newt.openTimestampedFile("hashtag-" + tag, 'tweets.txt') writer = csv.writer(fo) for tweet in tweets: writer.writerow([ tweet['from_user_id'], tweet['from_user'], tweet['text'].encode('ascii', 'ignore'), tweet['to_user_id'], tweet['created_at'] ]) fo.close() newt.report_hashtagsearch('hashtag-' + tag, tweeters, tags) for t in sorted(tags, key=tags.get, reverse=True): print t, tags[t] limit = 1
try: # sampleSize=int(sys.argv[4]) # 1400 24hr max due to dyno cycling sampleSize='1350' except: sampleSize='all' #---------------------------------------------------------------- tw={} if typ=="followers": tw=newt.getTwitterFollowersDetailsByIDs(api,user,sampleSize) else: tw=newt.getTwitterFriendsDetailsByIDs(api,user,sampleSize) f=newt.openTimestampedFile(user+'/'+typ,'sample'+str(sampleSize)+'tweeps.txt') for tweep in tw: f.write(str(tweep)+'\n') f.close() report("List members:") for i in tw: report(tw[i].screen_name) ''' report("List members:") for i in tw: report(tw[i].screen_name) ''' #newt.gephiOutputFile(api,user+'/'+typ, tw,'outerfriends') newt.gephiOutputFile(api,user+'/'+typ, tw)