1

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", "[email protected]")
    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)
3
  • Please provide a MCVE to reproduce the problem. Commented Jun 30, 2016 at 13:47
  • 1
    Are you sure your Tor port is 9150 and not 9050? I'd also leave ssl and ftp proxy/port settings empty since Tor is not any of those. Commented Jun 30, 2016 at 15:20
  • I deleted the SSL and FTP proxy and port settings and it worked. I also used port 9150. Thanks Commented Jun 30, 2016 at 19:00

1 Answer 1

3

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", "[email protected]")
    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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.