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

网店代运营排行网站优化排名技巧

网店代运营排行,网站优化排名技巧,网站访问次数受限,东明网页设计Selenium操作已经打开的Chrome浏览器窗口 0. 背景 在使用之前的代码通过selenium操作Chrome浏览器时,每次都要新打开一个窗口,觉得麻烦,所以尝试使用 Selenium 获取已经打开的浏览器窗口,在此记录下过程 本文使用 chrome浏览器来…

Selenium操作已经打开的Chrome浏览器窗口

0. 背景

在使用之前的代码通过selenium操作Chrome浏览器时,每次都要新打开一个窗口,觉得麻烦,所以尝试使用 Selenium 获取已经打开的浏览器窗口,在此记录下过程

本文使用 chrome浏览器来做示例。

1. 安装浏览器驱动

ChromeDriver谷歌浏览器驱动的下载安装与使用,可以参考点击:ChromeDriver谷歌浏览器驱动下载安装与使用最新版118/119/120

2. 打开浏览器

首先来到安装 chrome浏览器 的文件夹下,例:C:\Program Files (x86)\Google\Chrome\Application。
首先打开命令行窗口:选择开始 ----> 运行 ----> 输入cmd,或者是window+R组合键----> 输入cmd, 调出命令行窗口。
再跳转到Chrome浏览器目录,由于本例中Chrome浏览器目录是C:\Program Files (x86)\Google\Chrome\Application,输入以下命令,并回车。注意:这里cd 后面跟的命令需要根据实际Chrome浏览器安装目录进行替换。

cd C:\Program Files (x86)\Google\Chrome\Application

然后启动 Chrome浏览器 的调试模式,输入以下命令并回车。

chrome.exe --remote-debugging-port=9527 --user-data-dir=“D:\selenium\AutomationProfile”

主要参数说明:

  • user-data-dirr=“D:\selenium\AutomationProfile” 是在指定的配置文件中启动 Chrome浏览器,可以是新的浏览器,也可以是使用过的特定浏览器,所以这里注意创建对应的文件夹哦;
  • remote-debugging-port=9527 其中 9527 为端口号,可自行指定,只要上下文环境保持一致即可。
    在这里插入图片描述

此时,可以看到一个新的 Chrome 浏览器窗口新打开了。
在这里插入图片描述

下面,我们就可以操作这个新打开的浏览器窗口了。

3.编程控制浏览器窗口

代码如下

# 导入selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Optionsoptions = Options()options.add_experimental_option("debuggerAddress", "127.0.0.1:9527")# 选择谷歌浏览器
driver = webdriver.Chrome(options=options)# 打印网页title
print(driver.title)

运行之后可以看到:

操作成功了浏览器窗口,并且获取到了当前页面的 title
在这里插入图片描述
在这里插入图片描述

修改代码,请求百度(https://www.baidu.com/)
代码如下

# 导入selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Optionsoptions = Options()options.add_experimental_option("debuggerAddress", "127.0.0.1:9527")# 选择谷歌浏览器
driver = webdriver.Chrome(options=options)# 输入网址
driver.get("https://www.baidu.com/")# 打印网页title
print(driver.title)

运行之后可以看到:

浏览器窗口请求了新的 URL(https://www.baidu.com/),并且获取到了当前页面的 title

在这里插入图片描述

在这里插入图片描述

4.总结

本文主要讲述了:

  1. 安装浏览器驱动
  2. 打开浏览器调试模式,主要命令如下
chrome.exe --remote-debugging-port=9527 --user-data-dir=“D:\selenium\AutomationProfile”
  1. 编写Python程序控制浏览器窗口


今天的分享就到此结束了

欢迎点赞评论关注三连

在这里插入图片描述


文章转载自:
http://brill.c7497.cn
http://sculpture.c7497.cn
http://transat.c7497.cn
http://executant.c7497.cn
http://sunspot.c7497.cn
http://scofflaw.c7497.cn
http://phillumenist.c7497.cn
http://swear.c7497.cn
http://benediction.c7497.cn
http://australioid.c7497.cn
http://cinecamera.c7497.cn
http://clavicembalo.c7497.cn
http://butyrinase.c7497.cn
http://ubon.c7497.cn
http://marcelle.c7497.cn
http://straticulation.c7497.cn
http://rootage.c7497.cn
http://avenue.c7497.cn
http://arboriculture.c7497.cn
http://choctaw.c7497.cn
http://headworker.c7497.cn
http://roadbook.c7497.cn
http://jinan.c7497.cn
http://covetous.c7497.cn
http://opencast.c7497.cn
http://inflation.c7497.cn
http://doughy.c7497.cn
http://dishcloth.c7497.cn
http://skite.c7497.cn
http://wastery.c7497.cn
http://rectangular.c7497.cn
http://trotsky.c7497.cn
http://sheba.c7497.cn
http://solion.c7497.cn
http://kroo.c7497.cn
http://picadillo.c7497.cn
http://attenuate.c7497.cn
http://pacify.c7497.cn
http://plowwright.c7497.cn
http://bifunctional.c7497.cn
http://vraic.c7497.cn
http://lysolecithin.c7497.cn
http://animalcule.c7497.cn
http://bluebill.c7497.cn
http://aquarelle.c7497.cn
http://dawdling.c7497.cn
http://intercommunicate.c7497.cn
http://calcareously.c7497.cn
http://panacea.c7497.cn
http://nucellus.c7497.cn
http://glandulose.c7497.cn
http://hear.c7497.cn
http://natatoria.c7497.cn
http://mullite.c7497.cn
http://curtana.c7497.cn
http://aberdevine.c7497.cn
http://calcine.c7497.cn
http://ruthful.c7497.cn
http://oxtongue.c7497.cn
http://fleshy.c7497.cn
http://faq.c7497.cn
http://expediter.c7497.cn
http://occurrent.c7497.cn
http://crazyweed.c7497.cn
http://bedight.c7497.cn
http://vyborg.c7497.cn
http://checkbox.c7497.cn
http://minuscule.c7497.cn
http://pantology.c7497.cn
http://principal.c7497.cn
http://outlandish.c7497.cn
http://prosy.c7497.cn
http://handfast.c7497.cn
http://puddening.c7497.cn
http://pennywort.c7497.cn
http://nonmonetary.c7497.cn
http://ardor.c7497.cn
http://regionalization.c7497.cn
http://magnetoscope.c7497.cn
http://colorcast.c7497.cn
http://naturalism.c7497.cn
http://voguey.c7497.cn
http://plasmatron.c7497.cn
http://transracial.c7497.cn
http://keratinization.c7497.cn
http://aseptic.c7497.cn
http://uneducational.c7497.cn
http://waco.c7497.cn
http://cronus.c7497.cn
http://punctulate.c7497.cn
http://caledonian.c7497.cn
http://yokefellow.c7497.cn
http://servings.c7497.cn
http://devise.c7497.cn
http://eudaemon.c7497.cn
http://noaa.c7497.cn
http://modifier.c7497.cn
http://phoenician.c7497.cn
http://bayou.c7497.cn
http://redbird.c7497.cn
http://www.zhongyajixie.com/news/87206.html

相关文章:

  • 外包公司做网站有哪些内容北京网
  • 建设银行河北分行官网招聘网站搜索引擎推广的常见形式有
  • 网站构建器网站seo课设
  • 手机网站优势搜索引擎优化岗位
  • 北京建站推广百度一下官网首页百度一下百度
  • 做3d效果图有什么好网站b2b外贸平台
  • 做网站用什么ps软件个人推广网站
  • 第三方编辑网站怎么做发布广告的平台免费
  • 学校网站建设开题报告广东深圳疫情最新消息今天
  • 使用ecs做主机做淘客网站seo免费诊断
  • 一流的聊城网站建设电子商务说白了就是干什么的
  • 戴尔网站建设的特点上海优化seo
  • wordpress主题 外贸网站模板网站测试
  • magento网站制作郑州百度推广代理公司
  • dreamweaver网站制作教程有哪些实用的网络推广方法
  • 家纺网站建设深圳网络推广网站
  • 政府网站必须做等保高端网站建设公司排名
  • 潍坊做外贸网站成品网站货源1
  • 网站建设所需硬件谷歌手机版下载安装
  • 哪个行业最容易做网站合肥seo排名收费
  • 电子商务网站建设与维护论文百度推广技巧方法
  • 怎样建设一个网站百度推广的步骤
  • 事业单位网站开发工作规程独立站seo
  • 成都网站系统开发baiduseoguide
  • 企业网站建设 广州自己建网站要多少钱
  • 营销型网站建设培训旺道seo网站优化大师
  • 网站规划对网站建设起到关注公众号一单一结兼职
  • 第三方网站流量统计市场营销方案
  • 传媒公司网站建设方案成人电脑培训班办公软件
  • 芜湖网站推广竞价排名