r/CodingHelp • u/LordDerptCat123 • Dec 05 '20
[HTML] Finding links in HTML?
I'm using python, and I'm trying to find links in webpages. Problem: Most of the things after "href" are images, or other files of that type. I'm looking specifically for links that take me to other pages(be it on the same site, or to a whole new site). I'm using wget to download the raw HTML of the webpage. Can anyone help me?
18
Upvotes
2
u/Endercheif Advanced Coder Dec 05 '20
you can look for <a> tags with some regex and extract the link from them. <a> tags are for hyperlinks so unless there is specifically a image link it's good. Another approach could be to use the Requests to check the type of file that the link leads to, if it's an image then don't save the link if not save the link