当前位置: 首页 > news >正文

发布网站的空间wordpress免费主题排行榜

发布网站的空间,wordpress免费主题排行榜,推广文案怎么写,洛阳网站推广公司电话环境#xff1a;Windows 版本#xff1a;python3#xff0c;selenium 4.11.2 写这个是方便自己重装电脑时重新装 Selenium#xff0c;懒得每次都重新找链接。 文章目录 1 装ChromeEdge其他浏览器 2 运行报错RequestsDependencyWarning: urllib3 (1.26.9) or chardet (3.0.4… 环境Windows 版本python3selenium 4.11.2 写这个是方便自己重装电脑时重新装 Selenium懒得每次都重新找链接。 文章目录 1 装ChromeEdge其他浏览器 2 运行报错RequestsDependencyWarning: urllib3 (1.26.9) or chardet (3.0.4) doesn‘t match a supported version打开了浏览器但是没有显示网页 / Service连接失败invalid argument: invalid locator (Session info: MicrosoftEdge102.0.1245.44) 3 老代码报错DeprecationWarning: executable_path has been deprecated, please pass in a Service objectAttributeError: WebDriver object has no attribute find_elements_by_xpath 4 经典代码片段分享 1 装 Chrome 和 Edge 或其他浏览器任选其一。 Chrome 首先终端运行 pip3 install selenium4.11.2官网下载Chromehttps://www.google.cn/intl/zh-CN/chrome/ 安装好Chrome之后查看Chrome版本chrome://settings/help 如果Chrome版本大于114官网下载与Chrome版本对于的ChromeDriverhttps://googlechromelabs.github.io/chrome-for-testing/往下翻翻就能看到下载链接 如果Chrome版本小于等于114官网下载ChromeDriver链接https://chromedriver.chromium.org/downloads。 解压下好的ChromeDriver.zip把里面的exe拖出来并记住放到了哪个路径。 写代码引入driver from selenium import webdriver from selenium.webdriver.chrome.service import Services Service(D:/software/chromedriver.exe) driver webdriver.Chrome(services)结合Options使用的方式 from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Optionsoptions Options() options.add_argument(user-agentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36) # UA s Service(D:/software/chromedriver.exe) driver webdriver.Chrome(services, optionsoptions)Edge 首先终端运行 pip3 install selenium4.11.2官网下载Edgehttps://www.microsoft.com/en-us/edge/download 安装好Edge之后查看Chrome版本edge://settings/help 官网下载与Edge版本对于的webDriverhttps://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 解压下好的edgeDriver.zip把里面的exe拖出来并记住放到了哪个路径。 from selenium import webdriver from selenium.webdriver.edge.service import Services Service(D:/software/msedgedriver.exe) edge webdriver.Edge(services)结合Options使用的方式 from selenium import webdriver from selenium.webdriver.edge.service import Service from selenium.webdriver.edge.options import Optionsoptions Options() options.add_argument(user-agentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36) # UA s Service(D:/software/msedgedriver.exe) edge webdriver.Edge(services, optionsoptions)其他浏览器 浏览器本身直接搜索下载驱动driver可参考selenium官网的驱动下载列表 https://www.selenium.dev/zh-cn/documentation/webdriver/troubleshooting/errors/driver_location/#download-the-driver。 2 运行报错 以下是运行Selenium可能遇到的问题 RequestsDependencyWarning: urllib3 (1.26.9) or chardet (3.0.4) doesn‘t match a supported version 解决更新requestspip3 install --upgrade requests 打开了浏览器但是没有显示网页 / Service连接失败 原因浏览器驱动版本下载错误。 解决请自行确定浏览器版本并重新下载驱动driver。 invalid argument: invalid locator (Session info: MicrosoftEdge102.0.1245.44) 两种原因 ① 浏览器版本和驱动版本不一致请自行确定浏览器版本并重新下载驱动driver ② 代码打错了。比如edge.find_elements(by//div)正确的是edge.find_elements(byxpath,value//div)。 3 老代码报错 Selenium 4重构过API 发生了一些变化。以下是常见报错 DeprecationWarning: executable_path has been deprecated, please pass in a Service object 原因查询当前版本重构后的函数是之前的 executable_path 被重构到了 Service 函数里。所以新版的selenium不能继续用executable_path而是应该写成Service。 DeprecationWarning 警告的类型错误的意思都是该类型的警告大多属于版本已经更新所使用的方法过时。 解决webdriver.Edge(executable_path/pathto/webdriver.exe, optionsoptions) 改成 webdriver.Edge(serviceService(/pathto/webdriver.exe), optionsoptions)意思是去掉代码中的executable_path用Service如本文的第一节装里提供的示例代码那样写。 参考selenium 报错 DeprecationWarning: executable_path has been deprecated, please pass in a Service object AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_xpath’ 原因新的driver类没有find_elements_by_xpath方法了 解决改成find_elements(byxpath, value查找路径)。 快速替换find_elements_by_xpath( → find_elements(byxpath,value。 4 经典代码片段分享 from selenium import webdriver from selenium.webdriver.edge.service import Service from selenium.webdriver.edge.options import Optionsdef connectchrome():连接chrome浏览器实现无痕浏览# driver_path os.getcwd() /chromedriver.exe# s Service(driver_path)s Service(D:/software/chromedriver.exe) # 注意改成自己的driver路径options Options()options.add_argument(log-level3)options.add_argument(--incognito)options.add_argument(--no-sandbox)options.add_argument(--disable-dev-shm-usage)options.add_experimental_option(useAutomationExtension, False)options.add_experimental_option(excludeSwitches, [enable-automation])prefs {profile.default_content_setting_values: {images: 2,}}options.add_experimental_option(prefs, prefs)options.add_argument(--disable-blink-featuresAutomationControlled)options.add_argument(user-agentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36)driver webdriver.Chrome(services, optionsoptions)driver.execute_cdp_cmd(Page.addScriptToEvaluateOnNewDocument, {source: Object.defineProperty(navigator, webdriver, {get: () undefined})})driver.set_window_size(1280, 800)driver.set_window_position(100, 100)time.sleep(2)return driver
http://www.pierceye.com/news/675594/

相关文章:

  • 杭州网站制作公司网站厦门网站建设 首选猴子网络
  • 公司如何建站合肥网站设计
  • wordpress单页导出wordpress head 优化
  • 建筑模版东莞网站建设技术支持北京网页制作服务商
  • 网站html地图怎么做的wordpress 国内视频网站
  • 哪个网站做的简历比较好龙岗做网站公司icxun
  • 海外网站开发网站打开慢怎么回事
  • 外贸导向企业网站搜索引擎大全排名
  • 网站域名怎么做变更企业查询系统
  • 12306网站多少钱做的怎么研发软件app
  • 手机端建站井冈山保育院网站建设
  • 服装设计网站怎么做wordpress网站商务通
  • 重庆建设医院官方网站医疗网站源码
  • 大学生想做网站天元建设集团有限公司商业承兑汇票拒付最新消息
  • 怎么区分营销型网站文章类型的网站模版
  • 网站充值接口怎么做国家企业官网查询系统
  • 厦门网站建设工程网站备案幕布大小
  • 做家教去什么网站滕州做网站哪家好
  • 深圳市涂能装饰设计公司网站网站建设活动策划方案
  • 建设三合一网站找设计公司上哪个网站
  • 代理ip做网站流量饭店网站模板
  • 保险网站查询软件开发工程师和程序员的区别
  • 江都区城乡建设局网站马局下载app下载安卓免费
  • 网站做后台kuler 网站
  • 北京建网站公司飞沐扬中信息网
  • 商河网站建设公司南县网站建设推荐
  • 湛江企业网站建站模板网站开发 平台
  • c做的网站app开发制作专业吗
  • 杭州做网站公司做网站的文章
  • 那里有制作网站公司做网站需要了解的内容