使用 Python 自动填写 Web 浏览器表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28932205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 03:55:13  来源:igfitidea点击:

Automatizing web browser form filling in Python

pythonscriptingbots

提问by Josh Desmond

Question:

题:

Hi. I am a beginner trying to learn Python, and for one of my first projects I want to write a script that will fill out a survey automatically for me. I am familiar with coding, and I have most of the code written to solve this problem. What I am struggling is to write a method that will hit button #1 in question #1, or that will push any given button. One way I've realized I can do this, is perhaps by writing a script to press tab-> up-> down-> tab-> up -> down in the order needed to answer all of the questions.

你好。我是一个试图学习 Python 的初学者,对于我的第一个项目,我想编写一个脚本,该脚本将自动为我填写一份调查问卷。我熟悉编码,并且我编写了大部分代码来解决这个问题。我正在努力编写一个方法,可以在问题 #1 中点击按钮 #1,或者按下任何给定的按钮。我意识到我可以做到这一点的一种方法,也许是编写一个脚本,按照回答所有问题所需的顺序按 tab-> up-> down-> tab-> up -> down。

Here is an image of what the survey looks like (CSS was disable for clarity). http://i.imgur.com/Tn94KFA.jpg

这是调查的图像(为了清晰起见,禁用了 CSS)。 http://i.imgur.com/Tn94KFA.jpg

What is one way to go about writing a method to push a radio button?

编写按下单选按钮的方法的一种方法是什么?



[Disclaimer]: I have checked out the following questions but they were of no use to me in my current situation:

[免责声明]:我已经检查了以下问题,但在我目前的情况下它们对我没有用:

采纳答案by Mikko Ohtamaa

There are Python libraries and tools for automatizing browser actions. StackOverflow.com is not a place to ask for an recommendation for such a tool and thus moderators will close this question (SO is usually asking a help for particular problem, not for broad help and tutoriing requests). However here are some starting points for you

有用于自动化浏览器操作的 Python 库和工具。StackOverflow.com 不是要求推荐此类工具的地方,因此版主将关闭此问题(SO 通常是针对特定问题寻求帮助,而不是针对广泛的帮助和辅导请求)。但是这里有一些起点

For installing Python packages please refer to official package installation tutorial.

安装Python包请参考官方包安装教程