I'm testing proxy settings in python using the e621 api. When i query this website through a browser (which also has tor running) i can access the api just fine, but when python tries the same thing it returns with:
"403 Forbidden"
my theory regarding the issue is that I'm being blocked by a capcha that apperes sometimes when i access sites through tor
I'll leave the source and error messages here for any of my fellow python neck-beards
What can i do to prevent this 403 error from happening on tor
Source Code:
from lib.socks import monkey_patch as socks_patch socks_patch.monkey_patch() from lib.socks import socks_proxy_context from urllib.request import * import json, os, sys, time #responce = urlopen("https://e621.net/post/show/547303.json") with socks_proxy_context.socks_proxy_context(proxy_address=("127.0.0.1", 9150)): responce = urlopen("https://e621.net/post/show/547303.json") print(responce)
Error Message:
Traceback (most recent call last): File "api_scrapper.py", line 10, in <module> responce = urlopen("https://e621.net/post/show/547303.json") File "C:\Python34\lib\urllib\request.py", line 153, in urlopen return opener.open(url, data, timeout) File "C:\Python34\lib\urllib\request.py", line 461, in open response = meth(req, response) File "C:\Python34\lib\urllib\request.py", line 571, in http_response 'http', request, response, code, msg, hdrs) File "C:\Python34\lib\urllib\request.py", line 499, in error return self._call_chain(*args) File "C:\Python34\lib\urllib\request.py", line 433, in _call_chain result = func(*args) File "C:\Python34\lib\urllib\request.py", line 579, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
Updated