Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to code an automated bot that can browse and do operations on a webpage

I need to code a bot that needs to do the following:

Go to a jsp page and search for something by:

  • 1: writing something on a search box
  • 2: clicking the search button(submit button)
  • 3: clicking one of the the resulting buttons/links(same jsp page with different output)
  • 4: get the entire html of the new page(same jsp page with different output)

The 4th one can be done with screen scraping and I do not think I need help with it. But I need some guidance to do the options from 1 to 3. Any links or just some keyword that will help me google to learn about it will be appreciated. I plan to do this with java.

like image 364
Tunca Ersoy Avatar asked Mar 16 '11 09:03

Tunca Ersoy


People also ask

Can we create a bot using selenium?

So Selenium is widely used. And it is very popular for a great reason. Because it can help you to create tests for your web applications. And it can also help you to create online bots, which is very nice.


2 Answers

All you need is HTMLUnit

This is an extract from its description

HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.

P.S.: Had used it to build a web scraping project ;)

like image 76
Clyde Lobo Avatar answered Oct 31 '22 12:10

Clyde Lobo


Maybe it's not what you want, but you can try selenium : http://seleniumhq.org/

It's a web application testing system.

like image 8
joel1di1 Avatar answered Oct 31 '22 14:10

joel1di1