How can i fetch a HTML page and save it to my database in JAVA?is there any easy way to do that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Receiving a file over http is pretty easy using the URL class:
IOUtils is taken from org.apache.commons.io, the toString method reads the whole input stream into one String.
Unfortunately by using java.net.URL you cannot control anything (cookies, header information, ..) besides the website’s address :-/
Personally, I use this approach wherever I can since the HttpClient’s API is too complex (too many LOC) to simply retrieve the source code of a website.