python reptiles (3) + crawl all the links title

Introduction:
First grab one page of data - "View more information see the reason why is because the page -" so you can grab the first page of data, recycle page you can get all the data

Was arrested Address: http://jhsjk.people.cn/result/?area=402
divided 3

Here Insert Picture Description
Grab all the titles one data
Here Insert Picture Description
Here Insert Picture Description

import requests
from lxml import etree
# 页码的分页
r=requests.get('http://jhsjk.people.cn/result/?area=402').content

topic=etree.HTML(r)
title=topic.xpath('//div/ul/li/a/text()')
print(title)

``
==========翻页
分析
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190528174909449.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTY2NTYzNw==,size_16,color_FFFFFF,t_70)

翻页
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190528175121653.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTY2NTYzNw==,size_16,color_FFFFFF,t_70)
运用到代码中

![在这里插入图片描述](https://img-blog.csdnimg.cn/20190528175527736.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTY2NTYzNw==,size_16,color_FFFFFF,t_70)

import requests
from lxml import etree

for a in range(1,4):
m=‘http://jhsjk.people.cn/result/’+str(a)+’?area=402
l=requests.get(m).content
topic=etree.HTML(l)

title=topic.xpath('//div/ul/li/a/text()')
for x in title:
     print(x)

Guess you like

Origin blog.csdn.net/weixin_41665637/article/details/90644280