抓取国家的学校编码数据

https://wenku.baidu.com/view/610da44658eef8c75fbfc77da26925c52cc59198.html

import requests
from bs4 import *

pageSize=20
pageIndex=1

while True:
url="http://www.csh.edu.cn/moetc/mdepartmentExtAction!toMdepartmentExtListWdOuter.action?cityId=220100000000&mdepartmentExt.type=4&mdepartmentExt.parentId=220100000000&pageSize="+str(pageSize)+"&pageIndex="+str(pageIndex)

response = requests.post(url)
soup=BeautifulSoup(response.text,'html.parser')
arr1=soup.select('.h_tdListCenter')
arr2=soup.select(".h_tdListCenter1")

for i in range(0,len(arr1)):
schoolname=arr1[i].text.replace('<td class="h_tdListCenter" nowrap="nowrap" width="30%">','').replace('</td>','').replace(" ","")
number=arr2[i].text.replace('<td class="h_tdListCenter1" nowrap="nowrap" width="30%">','').replace('</td>','').replace(" ","")
print(schoolname.strip(),end=" ")
print(number.strip())

if len(arr1)==0:
break
else:
pageIndex=pageIndex+pageSize

猜你喜欢

转载自www.cnblogs.com/littlehb/p/9897200.html