Python urllib2 timeout when using Tor as a proxy?

I am using Python urllib2 with Tor as a proxy to access the website. When I open the main page of the site, it works fine, but when I try to view the login page (actually not logging in, but just browsing). I get the following error ...

URLError: <urlopen error (10060, 'Operation timed out')>

To counteract this, I did the following:

import socket
socket.setdefaulttimeout(None).

I still get the same timeout error.

  • Does this mean that the website is being disabled on the server side? (I don't know much about http processes, so sorry if this is a stupid question)
  • Is there a way to fix it so that Python can view the page?

Thanks Rob

+3
source share
3

Socket Python , "" .

, . , "Python-urllib", . :

request = urllib2.Request('site.com/login')
request.add_header('User-Agent','Mozilla/5.0 (X11; U; Linux i686; it-IT; rv:1.9.0.2) Gecko/2008092313 Ubuntu/9.04 (jaunty) Firefox/3.5')

-, URL-, - :

proxy = urllib2.ProxyHandler({"http":"http://127.0.0.1:8118"})  
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
+3

Tor, , - , Tor - . , .

0

urllib2.urlopen (url [, data] [, timeout])

An additional timeout parameter determines the timeout in seconds to block operations, such as attempting to connect (if not specified, the global default timeout setting will be used). This actually only works for HTTP, HTTPS, FTP, and FTPS connections.

http://docs.python.org/library/urllib2.html

0
source

Source: https://habr.com/ru/post/1710517/


All Articles