I have the following script to logon to a url,but on submit in the webpage i call
<input type=button value="go" onclick="Search()";>
How to do the same in the following script instead of submit……
import urllib, urllib2, time
username = "sumname"
password = "test"
interval = 10
data = {"username":username,"password":password,"submit":"sign in"}
value = urllib.urlencode(data)
request = urllib2.Request("http://127.0.0.1/accounts/login/",value)
print "request="%request
#while (1):
open = urllib2.urlopen(request)
response = open.read()
response=str(response)
print response
Thanks…
urllib and urllib2 are not the best ways to simulate browser interaction! You should rather be looking at mechanize (which does plug into urllib2). It’s possible to simulate such interaction on “bare” urllib2, but it’s just too much work and fragility to bother;-).