Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am trying to create an HTTP request bot to automate simple web tasks in JS. Filling out a forum, adding a product to a cart, clicking a button, etc. Currently, I am using Axios and Cheerio to scrape information from the site, but I'm not sure how to proceed from here and do something like click a button. I'm not sure what additional libraries I would have to use to be able to do something like click a button. To summarize if someone could provide a blueprint of how to use an HTTP request bot to click a button on a webpage I would really appreciate it! Thanks!

What I have tried:

I have created a browser-based automation bot using puppeteer before however, it is not that fast and cannot be scaled easily.
Posted
Updated 12-Mar-22 1:16am

1 solution

Axios and Cheerio are just http request and processing libraries. They DO NOT replace a full featured browser like puppeteer does. So, your first approach for 'pressing buttons' on a website was the right choice. Go back to puppeteer, maybe microsoft's playwright, selenium, webdriver, etc. or one of the wrapper frameworks like cypress (for testing). These really 'run' the webside, axios just downloads html. No JS is run, no interaction possible, hence, on more complex sites, there is nothing to 'click' (at least from within node,js as you can use axios from within the browser, but scraping will then be limited by cross origin domain request policies)!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900