码迷,mamicode.com
首页 > 其他好文 > 详细

selenium 定位标签

时间:2020-04-01 14:41:25      阅读:64      评论:0      收藏:0      [点我收藏+]

标签:请求   driver   text   ext   table   pytho   python学习   arch   sele   

from selenium import webdriver
from lxml import etree
import time


a = webdriver.Chrome(executable_path=r‘D:\python学习\其他\chromedriver.exe‘)
url = ‘https://jd.com‘
a.get(url) # 用户发起请求

search_input = a.find_element_by_id(‘key‘) # 定位到input框
search_input.send_keys(‘电脑‘) # 输入内容

btn = a.find_element_by_xpath(‘//*[@id="search"]/div/div[2]/button‘) # 定位到按钮
btn.click() # 点击按钮

page_text = a.page_source # 下载网页源码

a.quit()

selenium 定位标签

标签:请求   driver   text   ext   table   pytho   python学习   arch   sele   

原文地址:https://www.cnblogs.com/zjj999/p/12612326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!