A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/308667.html below:

disabling TCP connections, just for one script

disabling TCP connections, just for one script disabling TCP connections, just for one scriptAdam Monsen haircut at gmail.com
Fri Sep 9 17:03:58 EDT 2005
Another solution is using a deliberately misconfigured proxy:

import socket
socket.setdefaulttimeout(1)
import urllib
proxies = {'http': 'http://www.example.com:3128'}
url = 'http://www.google.com/'
opener = urllib.FancyURLopener(proxies)
f = opener.open(url)
print f.read()


>From this code I get the following exception:
"IOError: [Errno socket error] timed out"

...and that fits my needs nicely.

-- 
Adam Monsen
http://adammonsen.com/


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4