selenium提取网页文本:

import selenium
import selenium.webdriver
url="https://www.51shucheng.net/kehuan/santi/santi1/174.html"
driver=selenium.webdriver.Chrome()
driver.get(url)
data=driver.find_elements_by_xpath("/*")  #匹配url的所有网页源码
#print(type(data))
#<class 'list'>
for tag in data:       #遍历出所有内容
    print(tag.text)    #把所有的文本打印出来
driver.close()

 

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2022-12-23
  • 2021-03-27
  • 2021-06-20
  • 2021-11-04
  • 2021-07-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2022-01-03
  • 2022-12-23
  • 2021-11-02
  • 2018-12-26
  • 2022-12-23
相关资源
相似解决方案