Python爬虫案例:使用Selenium+gne爬取新闻网页

来自CloudWiki
跳转至: 导航搜索

代码

import time
from gne import GeneralNewsExtractor
from selenium.webdriver import Chrome

 
# 实例化一个浏览器,并添加chromedriver路径
chromedriver_path = "C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe"
driver = Chrome(chromedriver_path)
driver.get('https://www.toutiao.com/a6766986211736158727/')
time.sleep(3)
extractor = GeneralNewsExtractor()
result = extractor.extract(driver.page_source)
print(result)

参考文档

[1] http://www.python88.com/topic/52481

[2] https://blog.csdn.net/qq_39198486/article/details/82930025