Home  >  Q&A  >  body text

如何用Python实现网页按钮的自动点击?

问题可能描述的不是太清楚,举个例子:

多看每天都会推出限免书,在首页点击限免图片就可以进入当日限免的图书的界面,在限免书的界面点击领取按钮即可完成流程。

其中当日限免书的地址很容易获取,我现在疑惑的是如何用Python脚本实现和在网页上点击『领取』按钮相同的效果。

PHPzPHPz2743 days ago981

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 11:45:35

    It seems that everyone thinks from the perspective of code, why not think from the perspective of "interface"

    There is a magical python-based script, sikuli, "God's Eye".

    Just take a screenshot of the program and you will understand it at a glance.

    (Picture transferred from Open Source China)

    The UI in the screenshot of the program recognition system purely imitates user input/clicks, and even the input frequency is very reasonable. The old enemy of anti-bot algorithms and a good friend of QA.

    I used this to drag the 1000+ book, video and audio records recorded in my old account into my new account without being discovered by Douban that I was a robot.

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:45:35

    Use python’s sendkeys to directly simulate the keyboard, and use ctype extension to click the mouse. All you need to do is open the browser with python, enter the website, find the coordinates of the button (fixed in the program), and click it. But the simple one is fine, but the more complicated one requires a lot of considerations.

    reply
    0
  • Cancelreply