-1

How can I open a website and return some information from it in Java ? For example I want to go to http://xyz.com, enter my family name and return my national code

Hamid
  • 1
  • 1
  • Always search first before posting. There are a number of similar threads that may answer your question, or at least help you refine it , such as http://stackoverflow.com/questions/7822420/retrieve-information-from-a-url or http://stackoverflow.com/questions/359439/how-do-i-retrieve-a-url-from-a-web-site-using-java – Leigh May 18 '12 at 05:17

3 Answers3

1

You can use java.net.HttpURLConnection to connect to a website. For scraping information from the loaded website you can use a Java HTML Parser library (for example JSoup) to be able to traverse through the DOM and/or retrieve relevant pieces of information from the DOM.

Leigh
  • 28,765
  • 10
  • 55
  • 103
Niek Tax
  • 841
  • 1
  • 11
  • 30
0

With Selenium, that is a tool for testing web applications, you can do all that you say. Try to check its documentation

This is an example case example in java

richarbernal
  • 1,063
  • 2
  • 14
  • 32
0

If that site returns information in XML format, then its possible to do XML parsing to get the result you desire.

SAX is really handy in XML parsing in these cases.

Leigh
  • 28,765
  • 10
  • 55
  • 103
Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75