i'm writing bot in python using tweepy python 2.7. i'm stumped on how approach looking do. bot finds tweet id , appends text file. on later runs want use regex search file match , write if there no match within text file. intent not add duplicate tweet ids text file span large amount of numbers followed newline.
any appreciate!
/edit when try below code ide says match can't seen , syntax error result.
import re,codecs,tweepy qname = queue.txt tweets = api.search(q=searchquery,count=tweet_count,result_type="recent") codecs.open(qname,'a',encoding='utf-8') f: tweet in tweets: tweetid = tweet.id_str match = re.findall(tweedid), qname) #if match = false write, else discard , move on f.write(tweetid + '\n')
if correct,you need not bother regex etc. let special containers work you.i proceed non-duplicate-container dictionary
or set
e.g read data file dictionary
or set
, go extending id dictionary
or set
after write dictionary
or set
file.
e.g.
>>>data = set() >>>for in list('asddddddddddddfgggggg'): data.add(i) >>>data >>>set(['a', 's', 'd', 'g', 'f']) ## see 1 d , g
Comments
Post a Comment