Page 1 of 1

Bulk hyperlink testing

Posted: Sun Feb 17, 2019 8:39 pm
by rmcmeeking
I have an online post on Wordpress that was written in OpenOffice Writer and is about 130 pages long. Each page averages 2 to 3 hyperlinks to source material. It is in HTML on Wordpress. The links work fine unless some of the linked material goes away, which happens. What I'd like to see is a one step process to find any links that are no longer valid. Simple, no?

Re: Bulk hyperlink testing

Posted: Sun Feb 17, 2019 9:04 pm
by YODA

Re: Bulk hyperlink testing

Posted: Sun Feb 17, 2019 11:13 pm
by robleyd

Re: Bulk hyperlink testing

Posted: Mon Feb 18, 2019 1:45 am
by rmcmeeking
Thanks to both of you. I'll need to experiment some. But a process built into Writer should be preferable.

Re: Bulk hyperlink testing

Posted: Mon Feb 18, 2019 1:52 am
by Lupp
If all the links are in the bodytext of a text document opened in Writer, I would use something like the little Sub posted below. If you also need to treat hyperlinks anchored to TexPportions in cells of TextTables or in TextFrames, it's a bit more complicated.

Code: Select all

Sub showRemoveDeadLinks()
theDoc      = ThisComponent
theBodyText = theDoc.Text
For each para In theBodyText
  For Each piece In para
    hlU = piece.HyperLinkURL
    If hlU<>"" Then
      h = FileExists(hlU)
      If NOT h Then 
        piece.String = "[" & piece.String & "(" & hlU & ")dead" &"]"
        piece.HyperLinkURL=""
      End If
    End If
  Next piece
Next para
End Sub
===Edit 2019-02-18 01:42 (UCT + 1)===
I had to rectify the code a bit. The " h = ..." and the inner IF were not correctly placed. In consequence a "End If" was missing
(A short test of the Sub was done with LibO V 6.2.0.3 and with AOO V 4.1.5.)

Re: Bulk hyperlink testing

Posted: Tue Feb 19, 2019 12:26 am
by rmcmeeking
I tried 3 tools found online. All of them test the html, not the source document. So on a site like wordpress it tests their stuff too. Several extraneous errors there. Here's my review.
**validator3 was very thorough, even identified redirected links. It gives the html line number and the bad link.
**Gizmo's "Best free website link checker" is a downloadable exe. It did not identify any link problems.
**www.deadlinkchecker.com/website-dead-link-checker.asp is my favorite. Very fast and identifies bad links and the hyperlinked text. Did not identify redirects.

Re: Bulk hyperlink testing

Posted: Fri Feb 22, 2019 12:39 am
by ThomasH
I'd be surprised to learn that Wordpress doesn't have a plugin to check for this built by someone in the community.

Yes; here's the first one that came up in my Google search: https://wordpress.org/plugins/broken-link-checker/