0

I am trying to simulate a web request using python library. This is the get request query created by the browser(I have replaced the actual url)

http://myurl.asp?treg=8338033&dob=14/09/2003&sid=0.3582164869592499

My code is here.

def individual(reg,dob):

session = Session()
myurl='http://myurl.asp'

# HEAD requests ask for *just* the headers, which is all you need to grab the
# session cookie
session.head('http://myurl')
response = session.get(
    url=myurl,
    data={
        'treg': reg,
        'dob': dob,
        'sid':'0.4443253265244038'
    },
    headers={
        'Referer': 'http://myurl.htm'
    }
)

return response.text

It gives me invalid date response from server. But the same values sent through browser is successful. I have already tried yyyy-mm-dd format.

1 Answer 1

0

You are mixing up GET-style params with POST ones by using data instead of params in the request session.get call.

Python Request Post with param data

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.