问题描述
排序类似于机器人,我已经检查了一些网站,例如睡衣和抓痒的衣服,我知道如何打印网站数据,但仍然不知道如何与按钮交互.有人可以帮我提供一些说明性代码吗?
Sort of like a bot, i have already checked out some sites such as pyjamas and scrapy, I know how to print data of websites, but still dont know how to interact with buttons. Can somebody help me with some demonstarative code?
让我说我有一个表格
<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
</form>
我如何识别要单击的按钮,以便python可以为我单击?如果有人知道任何带有指示性代码的网站,我将非常高兴.
how do i identify the button to be clicked, so that python can click it for me?If anybody knows any sites with demonstarative code, i would be very pleased.
推荐答案
如果您想真正模拟浏览器,则可能需要查看硒,它使您可以控制真正的Web浏览器.
If you’re looking to really simulate a browser, you might want to look at Selenium, which allows you to control a real web browser.
如果您要与之交互的网站使用了大量JavaScript(例如onclick
处理程序),那么它会非常方便.
If the website you’re looking to interface with uses a lot of JavaScript (e.g. onclick
handlers), it can be very handy.
这篇关于使用python在Web浏览器中自动单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!