2017-05-14 50 views
0

我想通過模擬POST數據來繞過此頁面http://casesearch.courts.state.md.us/casesearch/當您單擊「我同意」時。我已經能夠用PHP來完成它,但由於某些原因,我無法在Python中重新創建請求。儘管發送了正確的POST數據,但響應始終是包含免責聲明的頁面。我想登陸的頁面的標題是「馬里蘭州司法機構案例搜索標準」。我正在使用Python 3.HTTP請求不能正確模擬表格

url = "http://casesearch.courts.state.md.us/casesearch/" 
    postdata = parse.urlencode({'disclaimer':'Y','action':'Continue'}) 
    postdata = postdata.encode("utf-8") 
    header = {"Content-Type":"application/x-www-form-urlencoded"} 

    req = request.Request(url,data=postdata,headers=header) 
    res = request.urlopen(req) 
    print(res.read()) 

回答

1

它看起來像你想發佈到的URL實際上是http://casesearch.courts.state.md.us/casesearch/processDisclaimer.jis。試試這個:

url = "http://casesearch.courts.state.md.us/casesearch/processDisclaimer.jis" 
postdata = parse.urlencode({'disclaimer':'Y','action':'Continue'}) 
postdata = postdata.encode("utf-8") 
header = {"Content-Type":"application/x-www-form-urlencoded"} 

req = request.Request(url,data=postdata,headers=header) 
res = request.urlopen(req) 
print(res.read()) 
+0

這樣做了。我想知道爲什麼http://casesearch.courts.state.md.us/casesearch/在curl中使用PHP?謝謝! – user3157910