爬取找例子网站的实例名录,方便浏览以寻找自己想要的例子
for page in range(1,page_total 1): if page != 1: print('这是第%d页实例:'%(page)) url = 'https://www.5t6t.com/examples/%s_%d.html'%(language_check,page) response = requests.get(url,headers=headers) html_str = response.content.decode() html_data = etree.HTML(html_str) ret = html_data.xpath("//a[@target = '_blank']") for subject in ret: print(subject.text) print('********************第%d页结束***************'%(page)) else: print('这是第1页实例:') ret = html_data.xpath("//a[@target = '_blank']") for subject in ret: print(subject.text)
评论