I have my python script which I guess is fine. I want to keep the script on the desktop and upon one click I want the script to run and open a browser(IE or firefox or chrome) and perform the script i.e. to log-in to a website.
import urllib, urllib2, cookielib
username = 'xyzusername'
password = 'xyzpassword'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'userid' : username, 'pass' : password})
resp = opener.open('http://www.gmail.com')
resp.read()
print resp
How do I run the 开发者_如何学编程script? Please help.
Hmmmm, your script is logging into a web site, but it's not opening a browser.
If you want to open a browser, you might be better off looking at Selenium:
- http://coreygoldberg.blogspot.com/2009/09/selenium-rc-with-python-in-30-seconds.html
- http://jimmyg.org/blog/2009/getting-started-with-selenium-and-python.html
- http://seleniumhq.org/
精彩评论