Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
2.40/5 (2 votes)
See more:
hello everyone, i want to download the source code of the webpage . i have used URL method and Jsoup method but not getting the exact data as mentioned in actual source code . for example-
HTML
<input type="image" name="ctl00$dtlAlbums$ctl00$imbAlbumImage" id="ctl00_dtlAlbums_ctl00_imbAlbumImage" title="Independence Day Celebr..." border="0" onmouseover="AlbumImageSlideShow('ctl00_dtlAlbums_ctl00_imbAlbumImage','ctl00_dtlAlbums_ctl00_hdThumbnails','0','Uploads/imagegallary/135/Thumbnails/IMG_3206.JPG','Uploads/imagegallary/135/Thumbnails/');" onmouseout="AlbumImageSlideShow('ctl00_dtlAlbums_ctl00_imbAlbumImage','ctl00_dtlAlbums_ctl00_hdThumbnails','1','Uploads/imagegallary/135/Thumbnails/IMG_3206.JPG','Uploads/imagegallary/135/Thumbnails/');" src="Uploads/imagegallary/135/Thumbnails/IMG_3206.JPG" alt="Independence Day Celebr..." style="height:79px;width:148px;border-width:0px;" /

>

in this tag the last attribute style is not detecting by the code of jsoup. and if i am downloading it from URL method it changes the style tag in border=""/> attribute.
can any body tell me the way to download the exact source code of a webpage.
my code is-
C#
URL url=new URL("http://www.apcob.org/");
  InputStream is = url.openStream();  // throws an IOException
    BufferedReader  br = new BufferedReader(new InputStreamReader(is));
    String line;
    File fileDir = new File(contextpath+"\\extractedtxt.txt");
    Writer fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileDir), "UTF8"));
    while ((line = br.readLine()) != null)
    {
     // System.out.println("line\n "+line);
      fw.write("\n"+line);
    }

   InputStream in = new FileInputStream(new File(contextpath+"extractedtxt.txt";));
    String baseUrl="http://www.apcob.org/";
    Document doc=Jsoup.parse(in,"UTF-8",baseUrl);
  System.out.println(doc);



second method i followed is-
C#
Document doc = Jsoup.connect(url_of_currentpage).get();
Posted
Updated 1-Feb-16 19:03pm
v5

1 solution

You can view the source of the web page in any browser.

IE - View the source code for a webpage[^]
Chrome - http://webdesign.about.com/od/chrome/a/view-source-chrome.htm[^]
 
Share this answer
 
Comments
Member 12301505 2-Feb-16 1:41am    
i know how to view the source code but i want to download it and save it in a file.
Member 12301505 2-Feb-16 1:42am    
and i want to do this using java code

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