karan / TPB

:cloud: Python API for ThePirateBay.
MIT License
331 stars 66 forks source link

Getting 403 Response when Iterating through Search Results #86

Closed alexanimal closed 8 years ago

alexanimal commented 8 years ago

Running Python 2.7 on Ubuntu 16.04

Getting a 403 urllib error? maybe not enough headers on the request?

Anyone else getting this? Below is the code from python console

from tpb import TPB t = TPB('https://thepiratebay.org') search = t.search('public domain') for item in search: ... print item.id ... Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/tpb/tpb.py", line 149, in items for item in super(Paginated, self).items(): File "/usr/local/lib/python2.7/dist-packages/tpb/tpb.py", line 59, in items request = urlopen(str(self.url)) File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib/python2.7/urllib2.py", line 435, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 548, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 473, in error return self._call_chain(_args) File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(_args) File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 403: Forbidden

alexanimal commented 8 years ago

Fixed by downloading Git Repo Manually and installing through tox.

I needed to use sudo, but dont if you dont need to. Run these commands inside the cloned repository folder

sudo -H pip install -U tox sudo tox