from selenium import webdriver
import time
# 创建 Webwd 实例对象,指明使用chrome浏览器驱动
wd = webdriver.Chrome(r'D:\tools-work\chromedriver_win32\chromedriver.exe')
wd.implicitly_wait(5)#等待时间 一定要写
# 链接地址
# wd.get('https://www.mps.gov.cn/n2253534/n2253535/index.html')
wd.get('https://www.mps.gov.cn/n2253534/n2253535/index.html')
titles = wd.find_elements_by_xpath('//*[@id="comp_7627565"]/ul/li/a')
for x in titles:
print(x.text)

该博客展示了如何利用Selenium的ChromeDriver在Python中实现网页自动化操作,包括设置等待时间、打开指定URL以及通过XPath获取页面上的多个元素。示例代码详细地解释了如何遍历并打印出列表项的文本内容。

1035

被折叠的 条评论
为什么被折叠?



