anunes Posted October 5, 2009 Share Posted October 5, 2009 Any one know a way to get all links from an html page and add them all to an array with php? Thanks. Link to comment Share on other sites More sharing options...
0 svnO.o Posted October 5, 2009 Share Posted October 5, 2009 Use fgets() or cURL to get the source code of an html page. Then use some basic string manipulation commands such as substr() (allows you to grab a part of the string) and stripos() (lets you find something in a string). Using those commands will allow you to search through the code for a href="" tags. Once you find the location of those tags (looping through the entire source), you can parse the string based on that and put them into an array. It's not that difficult really. If you need working examples you can go to PHP.net and look up the functions I recommended. If you can't figure out the logic behind what I just briefly explained then I can provide you with some actual code to get you started. Link to comment Share on other sites More sharing options...
0 anunes Posted October 5, 2009 Author Share Posted October 5, 2009 Use fgets() or cURL to get the source code of an html page. Then use some basic string manipulation commands such as substr() (allows you to grab a part of the string) and stripos() (lets you find something in a string).Using those commands will allow you to search through the code for a href="" tags. Once you find the location of those tags (looping through the entire source), you can parse the string based on that and put them into an array. It's not that difficult really. If you need working examples you can go to PHP.net and look up the functions I recommended. If you can't figure out the logic behind what I just briefly explained then I can provide you with some actual code to get you started. if you could provide the code would be fantastic. Thank you Link to comment Share on other sites More sharing options...
Question
anunes
Any one know a way to get all links from an html page and add them all to an array with php?
Thanks.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts