'urllib2.HTTPError: HTTP Error 410: Gone

I wrote the following program in python for tweet search in python :

#Importing the modules
import urllib2
import json

screen_name = "wordpress"

url = "https://api.twitter.com/1/statuses/user_timeline.json?screen_name=" + screen_name

data = json.load(urllib2.urlopen(url))

print len(data), "tweets"

for tweet in data:
    print tweet['text']

But I got the following errors. I am relatively new in Python.

File "twitter.py", line 9, in <module>
    data = json.load(urllib2.urlopen(url))
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 410: Gone

Please help.



Solution 1:[1]

A 410 error means that the resource is no longer available. This differs from "never existed". It means that the url is no longer available on the server, or has changed names. I suspect that the twitter api has changed.

For more information : 410 Error

Solution 2:[2]

I faced the same issue for pytube module and installed it as follows

python -m pip install git+https://github.com/Zeecka/pytube@fix_1060

Solution 3:[3]

Was getting the same error while following a pytube tutorial (titled "YouTube video downloader | Python project | Pytube | Easy Tutorial"). Fixed it by updating pytube via the following command in Windows Command Prompt:

python -m pip install --upgrade pytube

Hope that resolves your problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 0xsegfault
Solution 2 vijaylaxmi lendale
Solution 3 Paul G