1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python selenium 获取网页源代码

python selenium 获取网页源代码

时间:2023-03-07 21:10:38

相关推荐

python selenium 获取网页源代码

获取网页源代码:

引入组件:【from selenium import webdriver】、

【from selenium.webdriver.chrome.options import Options】

构建浏览器链接:

chrome_options = Options()chrome_options.add_argument('--headless')driver = webdriver.Chrome(options=chrome_options)

获取网页所有源代码:

driver.get_attribute('/telegraph')

获取指定位置网页源代码:

driver.get('/telegraph') # 打开网页# 获取指定标签下的网页源代码clsxpath = driver.find_element_by_xpath('//div[@class="b-c-e6e7ea telegraph-list"][' + str(count-i) + ']')# 转换为文本格式leachText =clsxpath.get_attribute('innerHTML')

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。