MatthewExpungement
MatthewExpungement

Reputation: 93

HTTP Request Not Mimicking Form Correctly

I'm trying to bypass this page http://casesearch.courts.state.md.us/casesearch/ by mimicking the POST data when you click "I Agree". I've been able to do it with PHP but for some reason I can't recreate the request in Python. The response is always the page with the disclaimer despite sending the correct POST data. The title of the page I want to land on is "Maryland Judiciary Case Search Criteria". I'm using Python 3.

    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())

Upvotes: 0

Views: 44

Answers (1)

Nick Frost
Nick Frost

Reputation: 490

It looks like the URL you want to post to is actually http://casesearch.courts.state.md.us/casesearch/processDisclaimer.jis. Try this:

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())

Upvotes: 1

Related Questions