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.

asif
  • 3
  • 2

1 Answers1

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

Wereii
  • 330
  • 5
  • 16