请知悉:本文最近一次更新为 2年 前,文中内容可能已经过时。

怎么装这些是你的事情,我只放上代码,配合Chrome实现访问网址的功能,脚本使用sys库实现获取命令行第一个参数来作为代理使用。

#coding = utf-8
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
PROXY = sys.argv[1]
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=https://%s' % PROXY)
chrome_options.add_argument('user-agent='+sys.argv[2])
prefs = {"profile.managed_default_content_settings.images":2}
chrome_options.add_experimental_option("prefs",prefs)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.delete_all_cookies()
chrome.get("https://tcsnake.com/s/ c=e1Vz8-47254&market=newTencent")
print (chrome.page_source)
sleep(10)
chrome.delete_all_cookies()
chrome.close();

如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《Python+Selenium实现设置HTTP代理User Agent无图清理Cookies访问网址并输出源码》相关的博文:


留言

Admin Avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌