Skip to content

Instantly share code, notes, and snippets.

@EkkoG
Created June 25, 2019 16:33
Show Gist options
  • Select an option

  • Save EkkoG/00d8458df877d156af0c47945d571881 to your computer and use it in GitHub Desktop.

Select an option

Save EkkoG/00d8458df877d156af0c47945d571881 to your computer and use it in GitHub Desktop.
河南省高考成绩查询
import requests
import time
from bs4 import BeautifulSoup
for i in range(1000):
headers = {
'Proxy-Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
'Origin': 'http://www.haedu.gov.cn',
'Upgrade-Insecure-Requests': '1'
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
'Referer': 'http://www.haedu.gov.cn/gaokao_cx/checkpoints.aspx',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,zh-TW;q=0.6',
}
data = {
'KSH': '',
'BMXH': '',
'SFZH': '',
'Issub': '1'
}
try:
response = requests.post('http://www.heao.gov.cn/PZQuery/PZCJQuery.aspx', headers=headers, data=data, verify=False)
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
arr = soup.find(id="PZCJAllQuery").find('table')
print(f'第 {i + 1} 次查询: ')
for ele in arr.find_all('tr'):
print(f"{ele.find_all('td')[0].get_text()} = {ele.find_all('td')[1].get_text()}")
# print(i)
# print(arr)
else:
print('出错了')
time.sleep(2)
except (KeyboardInterrupt, SystemExit):
raise
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment