python自动化打开网页
from selenium.webdriver.firefox.options import Options as FOptions
from selenium.webdriver.chrome.options import Options as Foptions
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
#firefox设置代理
profile = FirefoxProfile()
# 激活手动代理配置(对应着在 profile(配置文件)中设置首选项)
profile.set_preference("network.proxy.type", 1)
# ip及其端口号配置为 http 协议代理
profile.set_preference("network.proxy.http", "127.0.0.1")
profile.set_preference("network.proxy.http_port", 8080)
# 所有协议共用一种 ip 及端口,如果单独配置,不必设置该项,因为其默认为 False
profile.set_preference("network.proxy.share_proxy_settings", True)
#chrome设置代理
# options = FOptions()
options = FOptions()
chrome_options = webdriver.FirefoxOptions()
chrome_options.add_argument(\'--proxy-server=http://127.0.0.1:8080\')
chrome_options.add_argument(\'--ignore-certificate-errors\')
chrome_options.add_argument(\'disable-infobars\')
browser = webdriver.Firefox(executable_path="D:/geckodriver.exe",firefox_profile=profile)
browser.maximize_window()
browser.get(\'https://account.dianping.com/login?redir=http%3A%2F%2Fwww.dianping.com%2F\')
button = browser.find_element_by_xpath(\'/html/body/div/div[2]/div[5]/span\')
button.click()
以上是 python自动化打开网页 的全部内容, 来源链接: utcz.com/z/386720.html