• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create broken link checker  RSS feed

 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to create a broken link checker using java. I had created code for link checker but I want to get out bound link in a webpage.

How can I get that so. Please help me out this.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This problem exists out of two sub problems:
1) checking if a single source (HTML page, image, etc) exists
2) getting all sources from a single HTML page

The first one is not that hard. You can use URL and URLConnection for that. A short example:


The second one requires a bit more work, but the hardest part has been done for you. Create an HTML parser, then parse the contents. Again, a short example:
Of course this code only handles A and IMG elements, and only the HREF and SRC attributes. However, I'm sure you can expand it for all tags and attributes you need.
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. Now its working fine.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!