olivierthereaux / oldtweets Goto Github PK
View Code? Open in Web Editor NEWpython script to backup/delete old tweets from your timeline
python script to backup/delete old tweets from your timeline
A new issue arose. I haven't found yet why but it seems consistent and reproducible. Which makes me think that there is a missing module for logging in the code.
→ time cat credentials.txt | ./oldtweets.py --delete >> tweets-bkp.txt
Traceback (most recent call last):
File "./oldtweets.py", line 130, in <module>
sys.exit(main())
File "./oldtweets.py", line 109, in main
tweets_ids += [status.id for status in api.GetUserTimeline(page=i + 1, count=100)]
File "/Library/Python/2.7/site-packages/twitter.py", line 2680, in GetUserTimeline
json = self._FetchUrl(url, parameters=parameters)
File "/Library/Python/2.7/site-packages/twitter.py", line 3794, in _FetchUrl
response = opener.open(url, encoded_post_data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 392, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 410, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 370, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1194, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1157, in do_open
r = h.getresponse(buffering=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1013, in getresponse
response.begin()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 402, in begin
version, status, reason = self._read_status()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 366, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
real 13m0.195s
user 0m0.468s
sys 0m0.138s
Error output is
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0ca0' in position 13: ordinal not in range(128)
I was able to get around this by replacing
str(tweet.text).replace('\n', '').replace('\r', '')
with
tweet.text.encode('utf-8').strip()
Not sure it is a better replacement but it worked for me.
A little issue. when using
→ cat credentials.txt | ./oldtweets.py
Not sure yet why. It seems it might be related to GetUserTimeline. I wonder if twitter modified the format.
Traceback (most recent call last):
File "./oldtweets.py", line 131, in <module>
sys.exit(main())
File "./oldtweets.py", line 110, in main
tweets_ids += [status.id for status in api.GetUserTimeline(page=i+1, count=100)]
File "/Library/Python/2.7/site-packages/twitter.py", line 2680, in GetUserTimeline
json = self._FetchUrl(url, parameters=parameters)
File "/Library/Python/2.7/site-packages/twitter.py", line 3794, in _FetchUrl
response = opener.open(url, encoded_post_data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 392, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 410, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 370, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1194, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1157, in do_open
r = h.getresponse(buffering=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1013, in getresponse
response.begin()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 402, in begin
version, status, reason = self._read_status()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 366, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
I'm not sure what is wrong yet. But it seems there is an issue.
→ cat credentials.txt | ./oldtweets.py --dry-run
Traceback (most recent call last):
File "./oldtweets.py", line 138, in <module>
sys.exit(main())
File "./oldtweets.py", line 103, in main
add_statuses = api.GetUserTimeline(count=200, include_rts=True, page=timeline_page)
TypeError: GetUserTimeline() got an unexpected keyword argument 'page'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.