I've been trying to use Tor via Python only to come across the "Proxy server is refusing connection" error.
I've trying this method using the Stem library: http://www.thedurkweb.com/automated-anonymous-interactions-with-websites-using-python-and-tor/
Any help to fixing this error?
Here is the code:
import stem.process
from stem import Signal
from stem.control import Controller
from splinter import Browser
proxyIP = "127.0.0.1"
proxyPort = 9150
proxy_settings = {"network.proxy.type":1,
"network.proxy.ssl": proxyIP,
"network.proxy.ssl_port": proxyPort,
"network.proxy.socks": proxyIP,
"network.proxy.socks_port": proxyPort,
"network.proxy.socks_remote_dns": True,
"network.proxy.ftp": proxyIP,
"network.proxy.ftp_port": proxyPort
}
browser = Browser('firefox', profile_preferences=proxy_settings)
def interactWithSite(browser):
browser.visit("http://dogdogfish.com/python-2/generating-b2b-sales-data-in-python/")
browser.fill("comment", "But the thing is... Why would anyone ever want to do this? I must have thought that times...")
browser.fill("author", "Pebblor El Munchy")
browser.fill("email", "barack@tehwhitehouz.gov")
browser.fill("url", "https://upload.wikimedia.org/wikipedia/en/1/16/Drevil_million_dollars.jpg")
button = browser.find_by_name("submit")
button.click()
interactWithSite(browser)
I deleted the SSL and FTP proxy and port settings and it worked. I also used port 9150.
Here is the working code:
import stem.process
from stem import Signal
from stem.control import Controller
from splinter import Browser
proxyIP = "127.0.0.1"
proxyPort = 9150
proxy_settings = {"network.proxy.type":1,
"network.proxy.socks": proxyIP,
"network.proxy.socks_port": proxyPort,
"network.proxy.socks_remote_dns": True,
}
browser = Browser('firefox', profile_preferences=proxy_settings)
def interactWithSite(browser):
browser.visit("http://dogdogfish.com/python-2/generating-b2b-sales-data-in-python/")
browser.fill("comment", "But the thing is... Why would anyone ever want to do this? I must have thought that times...")
browser.fill("author", "Pebblor El Munchy")
browser.fill("email", "barack@tehwhitehouz.gov")
browser.fill("url", "https://upload.wikimedia.org/wikipedia/en/1/16/Drevil_million_dollars.jpg")
button = browser.find_by_name("submit")
button.click()
interactWithSite(browser)