以前以为PB不能做此类程序,今天在网上看到,赶紧收起来转发到BLOG上,以后可能用得上
string ls_get_url, ls_args
string ls_response_text, ls_status_text
long ll_status_code
long ps1, ps2, ps3, ps4
string srstr1, srstr2
n_cst_string lhv_string
OleObject loo_xmlhttp
string ls_nj, ls_deptno, ls_deptname, ls_spenme, ls_temp1, ls_temp2, ls_temp3
long isel_total=0, row, row_spe, lii, lij, li_rs, li_rsdet
ls_nj = trim(ddlb_1.text)
if ls_nj='' then
messageboxx('提示','请先选择年级!', Information!, OK!, 1)
return
end if
if dw_dept.rowcount()<=0 then return
ls_get_url = "http://" + trim(sle_1.text)+"/newcsu/common/search/classresult1.aspx"
dw_special.reset()
for row=1 to dw_dept.rowcount()
if dw_dept.getitemnumber(row,'isel')=1 then
isel_total++
ls_deptno = trim(dw_dept.getitemstring(row,'院系代码'))
ls_deptname = trim(dw_dept.getitemstring(row,'院系名称'))
//ls_args = "grade=06级%20&deptId=03%20&deptName=资源加工与生物工程学院"
ls_args = "grade="+ls_nj+"%20&deptId="+ls_deptno+"%20&deptName="+ls_deptname
try
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.4.0")
loo_xmlhttp.open ("GET",ls_get_url + "?" + ls_args, false)
loo_xmlhttp.send()
//Get our response
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.Status
//Check HTTP Response code for errors
if ll_status_code >= 300 then
messageboxx('提示','Web的GET请求失败!~r~n~r~n'+ls_response_text, Information!, OK!, 1)
else
//Get the response we received from the web server
ls_response_text = loo_xmlhttp.ResponseText
end if
srstr1 = ls_response_text
srstr2 = '~t</tr><tr style="color:#003399;background-color:White;">~r~n~t~t<td align="Center">'
ps1 = pos(ls_response_text, srstr2, 1)
if ps1=0 then continue
srstr1 = mid(ls_response_text, ps1+len(srstr2))
srstr1 = lhv_string.of_globalreplace(srstr1,srstr2, '')
srstr1 = lhv_string.of_globalreplace(srstr1,'</td><td align="Center">', '~t')
srstr1 = lhv_string.of_globalreplace(srstr1,'</td><td>', '~t')
srstr1 = lhv_string.of_globalreplace(srstr1,'</td>', '')
srstr1 = lhv_string.of_globalreplace(srstr1,'~t</tr>~r~n</table>~r~n~t~t~t</form>~r~n~t</body>~r~n</HTML>~r~n','')
//mle_1.text = srstr1
//Done so cleanup
loo_xmlhttp.DisconnectObject()
li_rs = long( f_fj_str(srstr1,'~r~n',0))
for lii=1 to li_rs
ls_temp1 = f_fj_str(srstr1,'~r~n',lii )
ls_temp2 = f_fj_str(ls_temp1, '~t', 1 )
ls_spenme = ls_temp2
ls_temp2 = f_fj_str(ls_temp1, '~t', 3 )
ls_temp2 = mid(ls_temp2,2) + '/'
li_rsdet = long(f_fj_str(ls_temp2,'/',0))
for lij=1 to li_rsdet
ls_temp3 = trim (f_fj_str(ls_temp2,'/',lij))
row_spe = dw_special.insertrow(0)
dw_special.setitem(row_spe,'isel', 1)
dw_special.setitem(row_spe,'zy', ls_spenme)
dw_special.setitem(row_spe,'bj', ls_temp3)
dw_special.setitem(row_spe,'yx', ls_deptname)
next
next
if dw_special.rowcount()>0 then
cb_getxs.enabled = true
else
cb_getxs.enabled = false
end if
catch (RuntimeError rte)
messageboxx('运行时错', rte.getMessage(), Information!, OK!, 1)
return
end try
end if
next
if isel_total=0 then
messageboxx('提示','请先选择院系!', Information!, OK!, 1)
return
end if