Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing python mechanize and also urllib2 with random proxy support
    text
    copied!<p>I've got some http proxies for example:</p> <pre><code>123.123.123.123:2312 121.111.3.89:8080 111.133.1.111:23810 114.113.1.113:23812 111.133.1.114:23810 </code></pre> <p>They all have the same username and password: <code>testuser</code> and <code>testpass</code></p> <p>I'm trying to incorporate <strong>random</strong> proxy support for the following:</p> <pre><code>import urllib2 import httplib def check(): try: urllib2.urlopen("", timeout = 60) return True except (IOError, httplib.HTTPException): return False </code></pre> <p>Also trying to incorporate it into the following:</p> <pre><code>import mechanize def gethtml(): post_url = "" browser = mechanize.Browser() browser.set_handle_robots(False) browser.addheaders = [('User-agent', 'Firefox')] try: html = browser.open(post_url).read() except Exception: return </code></pre> <p>And also onto the similar:</p> <pre><code>import mechanize def check2(): post_url = "" browser = mechanize.Browser() browser.set_handle_robots(False) browser.addheaders = [('User-agent', 'Firefox')] parameters = {'page' : '1', 'sortorder' : 'asc' } data = urllib.urlencode(parameters) try: trans_array = browser.open(post_url,data).read().decode('UTF-8') except Exception: return </code></pre> <p>My biggest problem is everything that I've tried, I get the following two errors:</p> <p><code>httperror_seek_wrapper: HTTP Error 407: Proxy Authentication Required</code></p> <p><code>HTTPError: HTTP Error 407: Proxy Authentication Required</code></p> <p>Is anyone able to help me create some working examples, it would be much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload