动态javascript爬取,接口网址无法打开了,不过可以参考其逻辑,比较简洁
#coding=utf-8import requestsimport jsonfrom prettytable import PrettyTable if __name__=='__main__': url = 'https://data-gkcx.eol.cn/soudaxue/queryProvince.html' row = PrettyTable() row.field_names = ["地区", "年份", "考生类别", "批次","分数线"] for i in range(1,34): data ={"messtype":"json", "page":i, "size":50, "callback": "jQuery1830426658582613074_1469201131959", "_":"1469201133189", } school_datas = requests.post(url,data = data).json() datas = school_datas["school"] for data in datas: row.add_row((data["province"] ,data["year"],data["bath"],data["type"], data["score"])) print(row)
评论