VFP下提取网页上的查询结果,添加到数据表中
CREATE CURSOR T (准考证号 C(14),报名序号 C(12))
INSERT INTO T VALUES ([13412401151786],[240121150901])
INSERT INTO T VALUES ([13412401150398],[240121150902])
INSERT INTO T VALUES ([13412401150480],[240121150903])
INSERT INTO T VALUES ([13412401150631],[240121150904])
在VFP中,用代码方式根据上面数据表中的信息,在下面的网页上,自动填写网页表单上的内容:
准考证号:
报名序号:
点击网页上的[查询]按钮后,将查询到的录取信息,添加到数据表中。
网址=[http://www.haedu.gov.cn/hadoe_plus/gk_cx/queryresult.aspx]
Clear
*!*ctxtZKZH = "13412401150631" && 准考证号
*!*ctxtSFZH = "" && 身份证号
*!*ctxtBMXH = "240121150904" && 报名序号
ctxtZKZH = "13412401151786" && 准考证号
ctxtSFZH = "" && 身份证号
ctxtBMXH = "240121150901" && 报名序号
*!*身份证号与报名序号选其一即可
oXML = Createobject("Microsoft.XMLHTTP")
oXML.Open("POST","http://www.heao.gov.cn/datacenter/pages/PZLQueryResult.aspx",.F.)
PostData = "__VIEWSTATE=%2FwEPDwUKLTQwOTg4OTExNGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFCHNiblF1ZXJ5RK%2FaLHspwwJ8UFsKykKhzwxE3so" + ;
"%3D&__EVENTVALIDATION=%2FwEWBQLg26fcAwKn4%2BXICwK047EHAqnjjcUHAoCT5K4FaOqfYwCnY8YpwFpF4HaFBuVsJto%3D&txtZKZH=" + ;
Alltrim(ctxtZKZH) + "&txtSFZH=" + Alltrim(ctxtSFZH) + "&txtBMXH=" + Alltrim(ctxtBMXH) + "&sbnQuery.x=62&sbnQuery.y=17" + Chr(13) + Chr(10)
oXML.setRequestHeader("Content-Length", Len(PostData))
oXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
oXML.Send(PostData)
Do While oXML.ReadyState <> 4
=Inkey(1)
Enddo
Do Case
Case oXML.Status = 200 && 请求被服务器正确相应
? "请求被服务器正确相应"
? "===================="
? "姓 名 : " + Strextract(oXML.responseText, [<td class="common"> ], [</td>])
? "录取院校 : " + Strextract(oXML.responseText, [<td class="common"> ], [</td>], 2)
=Strtofile(oXML.responseText, "abc.txt")
Modify File abc.txt
Case oXML.Status = 500 && 服务器内部错误
? "PostData 数据错误,或服务器内部错误"
Case oXML.Status = 404 && 路径错误
? "路径出错,找不到"
Otherwise
? "其他错误"
Endcase
Release oXML
oXML = Null