以编程方式提交Python中的表单? [英] Programmatically submitting a form in Python?

查看:125
本文介绍了以编程方式提交Python中的表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始使用Google App Engine& Python(作为借口;))。
如何正确提交这样的表单

 < form action =https://www.moneybookers .com / app / payment.plmethod =posttarget =_ blank> 
< input type =hiddenname =pay_to_emailvalue =ENTER_YOUR_USER_EMAIL@MERCHANT.COM>
< input type =hiddenname =status_url
<! - 等 - >
< input type =submitvalue =Pay!>
< / form>

不向用户公开数据

解决方案

这听起来像您正在寻找 urllib

以下是图书馆文档中发布的示例:

 >>>导入urllib 
>>> params = urllib.urlencode({'spam':1,'eggs':2,'bacon':0})
>>> f = urllib.urlopen(http://www.musi-cal.com/cgi-bin/query,params)
>>> print f.read()


Just started playing with Google App Engine & Python (as an excuse ;)). How do I correctly submit a form like this

<form action="https://www.moneybookers.com/app/payment.pl" method="post" target="_blank">
<input type="hidden" name="pay_to_email" value="ENTER_YOUR_USER_EMAIL@MERCHANT.COM">
<input type="hidden" name="status_url"
<!-- etc. -->
<input type="submit" value="Pay!">
</form>

w/o exposing the data to user?

It sounds like you're looking for urllib.

Here's an example of POSTing from the library's docs:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
>>> print f.read()

这篇关于以编程方式提交Python中的表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆