selenium打开多窗口和切换窗口

设置代理IP:
有时候频繁爬取一些两页。服务器发现你是爬虫后会封掉你的p地址・这时候我们可以更改代理IP・更改代理IP,不同的浏览器有不用的实现方式。这里以 Chrome览器为例来讲解

from selenium Import webdrlver
options=webdriver.Chromeoptions()
options.add_argument("proxy-server-http://110,73,2.24818123)
driyer_path=r"D\ chromedriver\chromedriver.exe"
driver=webdriver.Chrome(Executable_path=driver_path, chrome_ options=options)
driver.get('https://httobin.ore/ip')


MabE1ement元素:
from  selenium, weberiver, remote, webelenent import Webt1eent类是个获取出来的元素的所属类
有一些常用的属性:
1.get_attribute:这个标签的某个属性的值。
2.screentshot:获収当前页面的截图。这个方法只能在 driver上使用。
driver的对象类,也是继承自 WebElenent
更多请阅读相关源代码。

猜你喜欢

转载自blog.csdn.net/q947448283/article/details/85780588