Need to parse HTML document for links-- use a library like html5lib or something else?

Posted by Luinithil on Stack Overflow See other posts from Stack Overflow or by Luinithil
Published on 2012-09-07T15:14:01Z Indexed on 2012/09/07 15:38 UTC
Read the original article Hit count: 461

Filed under:
|
|

I'm a very newbie webpage builder, currently working on creating a website that needs to change link colours according to the destination page. The links will be sorted into different classes (e.g. good, bad, neutral) by certain user input criteria-- e.g. links with content the user would find of interest is colored blue, stuff that the user (presumably) doesn't want to see is colored as normal text, etc.

I reckon I need a way to parse the webpage for links to the content (stored in MySQL database), change the colors for all the links on the page (so I need to be able to change the link classes in the HTML as well) before outputting the adapted page to the user. I read that regex is not a good way to find those links-- so should I use a library, and if so, is html5lib good for what I'm doing?

© Stack Overflow or respective owner

Related posts about php

Related posts about html-parsing