我想对学生的期末考试成绩做一些数据研究 在http://diemthi.hcm.edu.vn/ enter image description here 在这个页面你需要插入你的“SoBaoDanh”来搜索你在最终测试中的点
例如 enter image description here enter image description here “SoBaoDanh”起始表格 02000001 至 02089275 所以我怎么能得到那个结果的洞 我的代码是这样写的
import subprocess
i = 2000001
while i < 2089275:
result = subprocess.check_output([print("'curl - F" + '"SoBaoDanh=0'+ str(i+1) +'"' + "diemthi.hcm.edu.vn/Home/Show'")])
print(result)
i +=1
答案 0 :(得分:1)
不要使用 curl
调用 subprocess
,而是使用 requests
库来发出这样的 http 请求
import requests as r
for i in range(2000001, 2089275):
res = r.post("http://diemthi.hcm.edu.vn/Home/Show", data={"SoBaoDanh": "0"+str(i)})
print(res.content)
由于结果是一个 HTML 文档,您可以使用像 bs4 这样的 HTML 解析器进一步过滤存储在 res.content
中的结果,以仅获取您需要的部分。