爬虫小练习3

import requests
from lxml import etree

link="http://www.santostang.com/"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0'
           }
r=requests.get(link,headers=headers)
html=etree.HTML(r.text)
title_list=html.xpath('//h1[@class="post-title"]/a/text()')
print(title_list)

 

posted @ 2020-04-02 20:17  vcxvxcv  阅读(110)  评论(0)    收藏  举报