【问题标题】:fill out a webform that uses javascript with python填写一个使用 javascript 和 python 的网络表单
【发布时间】:2013-04-14 06:13:43
【问题描述】:

我正在尝试通过提交特定值来使用 python 程序填写网络表单。问题是它使用javascript。我将发布我要填写的值的示例。

fo.addVariable("email","email@yahoo.com")
fo.addVariable("age","19")
fo.addVariable("gender","M")
fo.addVariable("line","hello")

这是页面上的值的示例。我想要做的是提交一个值并改变它。我目前正在尝试的是:

data = urllib.parse.urlencode({"line": "hello", "age": "50", "email":  "email@yahoo.com", "gender": "M"}).encode()
resp = urlreq.urlopen("http://url.com/update", data) 

这通常适用于大多数网络表单。但对于这个它不会。

【问题讨论】:

  • 第一件事:Java 与 Javascript 完全不同。

标签: webforms python-3.3


【解决方案1】:

在 python 2.7 中,urllib 没有属性 urllib.parse 并且末尾的 .encode() 函数是不必要的。

我认为你应该写的是

data = urllib.urlencode({"line": "hello", "age": "50", "email":  "email@yahoo.com", "gender": "M"})

【讨论】:

  • 我使用 python 3.3。加上没有任何值提交。
  • 这是python 3.3的正确语法
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-06
相关资源
最近更新 更多