How can i check a website for broken links with java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can i check a website for broken links with java

Is there any way to check all links from a website if there are broken links of link to images, files that does not exist

8th Jul 2018, 9:08 AM
Konstantinos Kotsis
Konstantinos Kotsis - avatar
5 Answers
+ 2
You could use a webscraper to gather all of the a tags and other links. Then parse the tags and collect the URLs in an array or something. Then send an HTTP request to each link. If the links don't either a 200 or 300 code, they're broken.
8th Jul 2018, 10:18 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 3
Konstantinos Kotsis I don't know how to write a webscraper. My guess is you'll have to download the page, split each element up into an array of sorts, and parse it like that. That's just a very basic one.
8th Jul 2018, 10:36 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 2
Let me know how it goes. Im interested to see this.
8th Jul 2018, 11:04 AM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
Thank you very much Ben. I will try to make some code
8th Jul 2018, 10:40 AM
Konstantinos Kotsis
Konstantinos Kotsis - avatar
0
i am interested in writing a webscraper code in java...
8th Jul 2018, 10:34 AM
Konstantinos Kotsis
Konstantinos Kotsis - avatar