Naval Naval - 1 year ago 125
Python Question

Python Urllib POST response is not fetching correct values

For learning POST parmaeter urllib, I'm trying to grab table values for a particular date in the following code entered in the parameters. However, it doesn't return the values for 12th September but instead response shows the date is 12th October.

Using POSTMAN, the response is returned for the correct date but with Python, I'm unable to obtain values for other than current month. Any explanation to what could be causing this? any help/suggestion is appreciated.

import urllib
import urllib2

url = ''

data = urllib.urlencode({'priceDate.month' : '09', '' : '12','priceDate.year':'2016','submit':'Show Prices'})
req = urllib2.Request(url, data)

response = urllib2.urlopen(req)

d =

print d

Answer Source

Just use requests module.

import requests as re
url = ""
parms = {'priceDate.month':'09','':'12','priceDate.year':'2016','submit':'CSV+Format'}
resp =, parms)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download