javahttphttp-posthttp-getweb-search

java: performing website search and getting the result


First of all I have to say, I do not want anybody to do my work for me.

I want to make an java application that will search for data on a particular website. It will look like this:

  1. I will type a keyword into my jTextField and than i will press my OK button
  2. after pressing Ok button my application will send request to that site and perform search on it. By searching I mean regular search on websites with textfield and search button. Not ctrl+f search.
  3. After searching the website my app will read the result and store it for example in an array.

How can I start? search on that website looks like this:

 <input id='searchText' type='text' name='text' value='zboží nebo kód' title='title'/>
 <input id='searchButton' type='submit' value='Hledej' />

Solution

  • You will need to check the entire html form or just check the request with the "Network" tab of Firebug or the equivalent built-in tool in Firefox or Chrome to find out if there are other fields, what the URL is and if the site expect an HTTP GET or HTTP POST request.

    Then you will need to make such a request using a HTTP client class (Apache HttpClient comes to my mind).

    You will get a web site as a result, which you will need to parse, either using a DOM parser or regular expressions.