我一直试图通过Python使用Tor只遇到“代理服务器拒绝连接”错误。
我正在使用Stem库尝试此方法: http://www.thedurkweb.com/automated-anonymous-interactions-with-websites-using-python-and-tor/
修复此错误的任何帮助?
以下是代码:
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)
答案 0 :(得分:3)
我删除了SSL和FTP代理和端口设置,但它确实有效。我也使用了端口9150。
以下是工作代码:
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)