小编sac*_*ale的帖子

如何使用Python连接到Tor浏览器

我正在尝试连接到Tor浏览器,但收到一条错误消息,指出“ proxyConnectFailure”,我尝试了多次尝试以了解Tor浏览器的基础知识以实现连接的任何想法,但如果有什么话可以挽救生命,那一切都是徒劳的:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary


binary = FirefoxBinary(r"C:\Users\Admin\Desktop\Tor Browser\Browser\firefox.exe")
profile = FirefoxProfile(r"C:\Users\Admin\Desktop\Tor Browser\Browser\TorBrowser\Data\Browser\profile.default")

# Configured profile settings.

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,
}
driver = webdriver.Firefox(firefox_binary=binary,proxy=proxy_settings)

def interactWithSite(driver):

    driver.get("https://www.google.com")    
    driver.save_screenshot("screenshot.png")

interactWithSite(driver)
Run Code Online (Sandbox Code Playgroud)

python proxy selenium tor firefox-profile

3
推荐指数
1
解决办法
1139
查看次数

在 Selenium Python 中使用 Keys.PAGE_DOWN 滚动

你好每个人都可以帮助我滚动https://www.grainger.com/category/black-pipe-fittings/pipe-fittings/pipe-tubing-and-fittings/plumbing/ecatalog/N-qu1?searchRedirect=产品

我想滚动这个使用

actions = ActionChains(browser)
actions.send_keys(Keys.PAGE_DOWN)
actions.perform()
Run Code Online (Sandbox Code Playgroud)

直到它到达滚动的底部,在那里它会找到一个元素“加载更多”

loadMoreButton = browser.find_element_by_css_selector(
                        ".btn.list-view__load-more.list-view__load-more--js")
loadMoreButton.click()
Run Code Online (Sandbox Code Playgroud)

然后庞塞单击加载更多按钮,它必须再次执行滚动操作,然后再次执行加载更多操作,直到加载更多按钮不可用。

我必须使用此页面向下操作,因为在页面滚动到元素之前元素不会加载,如果有人可以提出一些解决方案将有很大帮助

python lazy-loading web-scraping selenium-webdriver webdriverwait

2
推荐指数
1
解决办法
5987
查看次数