17.splash_case01

# 抓取今日头条,对比渲染和没有渲染的效果

import requests
from lxml import etree

# url = 'http://localhost:8050/render.html?url=https://www.toutiao.com&timeout=30&wait=0.5'
url = 'https://www.toutiao.com'

response = requests.get(url)

print(response.text)

tree = etree.HTML(response.text)

article_titles = tree.xpath('//div[@class="title-box"]/a/text()')

print(article_titles)
posted @ 2019-05-04 10:36  hank-li  阅读(108)  评论(0编辑  收藏  举报