Hi all, I'm having alot of trouble automating the submitting of form. I have an HTML page that works and it looks like this:
<form action='*script here*' enctype="multipart/form-data" method="post"> <input name="txtTitle" id="txtTitle" value="Video Title" maxlength="50" /><BR /> <input type="file" id="FileUploadedVideo" name="FileUploadedVideo" /><BR /> <input name="txtDescription" id="txtDescription" value="Description" maxlength="50" /><BR /> <input id="hdnADCID" name="hdnADCID" value="*app ID here*" type="hidden" /> <input type="submit" value="Submit" /> </form> When I put valid values for the handling script an app ID, this page works. Now I'm trying to turn this same functionality into a script. Here's my code: import urllib import os import urllib2 appID = *value here* video = os.path.normpath(os.getcwd() + '/news.wmv') title = 'News' desc = 'Here is a sample News video' uploader = *script here* print "Encoding url..." data = urllib.urlencode({"FileUploadedVideo": video, "hdnADCID" : appID, "txtTitle" : title, "txtDescription": desc}) user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent' : user_agent } print "Calling url..." req = urllib2.Request(uploader, data, headers) response = urllib2.urlopen(req) s = response.read() response.close() print "Writing results..." result = open('result.html','w') result.write(s) result.close() Does anybody have any suggestions? I keep on getting bad request, so I'm assuming that the html page is passing something that my script is not. Is there some way to scrape the POST request from the html form? Thanks, Zach
-- http://mail.python.org/mailman/listinfo/python-list