Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:using': 0.04; 'python?': 0.07; 'urllib2': 0.07; 'python': 0.07; 'be:': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'subject:python': 0.15; 'from:addr:kb1pkl': 0.16; 'from:name:corey richardson': 0.16; 'hello:': 0.16; 'message-id:@aim.com': 0.16; 'richardson': 0.16; 'subject:form': 0.16; 'processed': 0.19; 'header:In-Reply-To:1': 0.22; 'says': 0.25; 'subject:data': 0.26; 'object': 0.27; 'like.': 0.29; 'subject:post': 0.31; 'it.': 0.31; 'import': 0.32; 'to:addr :python-list': 0.32; 'page': 0.33; 'uses': 0.34; 'received:192': 0.34; 'difference': 0.35; 'received:192.168.0': 0.35; 'header :User-Agent:1': 0.35; 'response': 0.36; 'data': 0.37; 'received:192.168': 0.37; 'some': 0.37; 'but': 0.38; 'so,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.39; 'form,': 0.40; 'would': 0.40; 'received:205.188': 0.61; 'fed': 0.68; 'received:205.188.169': 0.72; 'url:php': 0.79; 'received:172.29.41': 0.84; 'data)': 0.91 Date: Mon, 04 Apr 2011 07:01:08 -0400 From: Corey Richardson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: using python to post data to a form References: <4D9958FA.8080606@tysdomain.com> In-Reply-To: <4D9958FA.8080606@tysdomain.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit x-aol-global-disposition: G X-AOL-SCOLL-SCORE: 0:2:477779360:93952408 X-AOL-SCOLL-URL_COUNT: 0 x-aol-sid: 3039ac1d29014d99a4f5321c X-AOL-IP: 71.181.115.87 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301914895 news.xs4all.nl 41117 [::ffff:82.94.164.166]:43258 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2561 On 04/04/2011 01:36 AM, Littlefield, Tyler wrote: > Hello: > I have some data that needs to be fed through a html form to get > validated and processed and the like. How can I use python to send data > through that form, given a specific url? the form says it uses post, but > I"m not really sure what the difference is. would it just be: > http://mysite.com/bla.php?foo=bar&bar=foo? > If so, how do I do that with python? > import urllib import urllib2 url = "http://www.foo.com/" data = {"name": "Guido", "status": "BDFL"} data = urllib.urlencode(data) request = urllib2.Request(url, data) response = urllib2.urlopen(request) page = response.read() So yeah, passing in a Request object to urlopen that has some urlencode'ed data in it. -- Corey Richardson