中国大学排名定向爬取
刚接触爬虫,记录一下爬取大学排名时遇到的问题。
爬取url:http://www.zuihaodaxue.cn/zuihaodaxuepaiming2019.html
爬取思路:
从网络上获取大学排名网页内容
提取网页内容中信息到合适的数据结构
利用数据结构展示并输出结果
先附上代码~
import requests
from bs4 import BeautifulSoup
import bs4
res = requests.get('http://www.zuihaodaxue.cn/zuihaodaxuepaiming2019.html')
res.encoding = 'utf-8'
demo = res.text
soup = BeautifulSoup(demo,'html.parser') #解析HTML界面,给出待解析内容以及解析器
tag1 = soup