Note that there are some explanatory texts on larger screens.

plurals
  1. POErrno 11004 getaddrinfofialed using urllib2 but not httplib
    primarykey
    data
    text
    <p>I am new to python and am trying to build a Google Scholar scrapper using scholar.py and TOR. Unfortunately, when I run the code below:</p> <pre><code>import scholar import csv import socks import socket import urllib2 import urllib import httplib from TorCtl import TorCtl socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050, True) socket.socket = socks.socksocket proxy_support = urllib2.ProxyHandler({"http" : "127.0.0.1.8118"}) opener = urllib2.build_opener(proxy_support) def connectTor(): socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050, True) socket.socket = socks.socksocket print "Connected to Tor" def newId(): socks.setdefaultproxy() conn = TorCtl.connect(controlAddr="127.0.0.1", controlPort=9051, passphrase="123") TorCtl.Connection.send_signal(conn, "NEWNYM") conn.close() connectTor() connectTor() for i in range(0, 10): print "case "+str(i+1) newId() conn = httplib.HTTPConnection("my-ip.heroku.com") conn.request("GET", "/") response = conn.getresponse() print(response.read()) </code></pre> <p>Everything is fine and the IP address is returned. However if I drop:</p> <pre><code>conn = httplib.HTTPConnection("my-ip.heroku.com") conn.request("GET", "/") response = conn.getresponse() print(response.read()) </code></pre> <p>and replace it with</p> <pre><code>urllib2.install_opener(opener) print(urllib2.urlopen("http://my-ip.heroku.com/").read()) </code></pre> <p>then I get the error message: "URLError urlopen error [Errno 11004] getaddrinfo failed."</p> <p>scholar.py uses urllib2 so I need it to work. Any thoughts are appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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