Pressing a button automatically in a web browser using python

As a bot, I already checked some sites, such as pajamas and scrapy, I know how to print website data, but still do not know how to interact with buttons. Can someone help me with some demo code?

Let's say I have a form

<form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form> 

how can i identify the button that needs to be clicked so that python can click it for me? If anyone knows any sites with demo code, I would be very pleased.

+6
source share
2 answers

If you really want to simulate a browser, you can look at Selenium , which allows you to control a real web browser.

If the website you want to interact with uses a lot of JavaScript (for example, onclick handlers), this can be very convenient.

+5
source

You can use mechanize . This provides an easy way to interact with websites.

+10
source

Source: https://habr.com/ru/post/886083/


All Articles