网络爬虫爬取信息的xpath怎么找


网络爬虫爬取该网站大学排名数据的xpath该怎么找

这个是接口,不是网页。网页才需要用到xpath去取数据。你这里直接拿到数据了。

不使用beautifulsoup和xpath,使用python字典和列表方法取值。
使用requests模块请求拿到数据后可以参考下面的代码取值。

import requests
resp = requests.get(url='http://ip').json
for item in resp['data']['rankings']:
    print(item['univNameCn'],item['ranking'])