简体   繁体   English

使用Python代码填写并提交Stulish表单

[英]Python code to fill and submit Stulish Form

I'm trying to write a Python code to submit a simple form. 我正在尝试编写Python代码以提交简单的表单。

http://stulish.com/soumalya01 http://stulish.com/soumalya01

[Edit : http://travelangkawi.com/soumalya01/ [编辑: http//travelangkawi.com/soumalya01/

When you use this link it returns a different page on form submit. 当您使用此链接时,它将在表单提交上返回另一个页面。 Is good for debugging] 适合调试]

Any code would do 任何代码都可以

Tried both mechanize and mechanical soup. 尝试机械化和机械汤。 Both are unable to handle the text fields. 两者均无法处理文本字段。 It does not have a name only ID. 它没有仅名称的ID。 But we are unable to get the element by ID 但是我们无法通过ID获取元素

Any Code would do as long as it works. 只要有效,任何代码都可以。 (Fill ABC in the text box and hit submit) (在文本框中填写ABC,然后点击“提交”)

I just followed the documentations of mechanize . 我只是遵循了mechanize的文档。 See sample code below: 请参见下面的示例代码:

from mechanize import Browser


br = Browser()

br.open('http://stulish.com/soumalya01')


br.select_form(nr=0)

form.set_all_readonly(False) #add this

br.form.set_value('ABC', nr=1)

print(br.form.controls[1])

br.submit()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM