Bootstrap

Python爬虫——爬取阳光高考网高校信息

在本次学习中主要爬取的内容如下
在这里插入图片描述
就简单粗暴直接献上代码吧

import requests
import time
import json
from bs4 import BeautifulSoup


def get_one_page():
    headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36'
    }
    num1=0
    num2=0
    num3=0
    for n in range(0, 8):
        offset = n * 20
        url = 'https://gaokao.chsi.com.cn/sch/search.do?searchType=1&ssdm=44&start=0' + str(offset)

        response = requests.get(url, headers=headers)

        soup = BeautifulSoup(response.text, "html5lib")
        hello = soup.find_all('td', class_="js-yxk-yxmc")

        for i in range(len(hello)):
            one=hello[i].a.te
;