import urllib
import urllib2
url = 'http://localhost/ehaat/index.php/log-in'
form_data = {'username': 'admin', 'password': 'admin'}
params = urllib.urlencode(form_data)
response = urllib2.urlopen(url, params)
data = response.read()
I am new to this urllib. So what is that I am doing wrong here? And also, can I use this to post data into a form (automating task of filling a form and click on submit) by taking random data's from files. I want to use this to test my website.
Error:
Traceback (most recent call last): File "D:\Users\iamhssingh\Documents\Python\url.py", line 2, in import urllib2 ImportError: No module named 'urllib2'
urllib2 was merged with urllib in python 3. Is a standard library in python 2 but not in 3.
Try this if you want to use the urlopen method
Also: