human
I am working on the file "201612_PyDataATL/Scaping_Talk.ipynb".
The first task is:
Problem

Sites might limit the revisit rate from a given IP address

Solution

Change IP addresses

Tor Scaper
<img src='../images/tor.png'>
Can you write Python program for it?
assistant
#Here is the Python program you requested.

class TorEngine(DefaultEngine):
    def __init__(self, pw = None, control = ("127.0.0.1", 9051), signal = Signal.NEWNYM,
            proxy_handler = urllib.request.ProxyHandler({"http": "127.0.0.1:8118"}),
            data = None, headers = { "User-Agent": DEFAULT_USER_AGENT }):
        if pw:
            self.pw = pw
        else:
            self.pw = getpass.getpass("Tor password: ")
        self.control = control
        self.signal = signal
        self.proxy_handler = proxy_handler
        proxy_opener = urllib.request.build_opener(self.proxy_handler)
        urllib.request.install_opener(proxy_opener)
        super(TorEngine, self).__init__(data, headers)