Jump to content

Get HTML source code


Guest FirefoxRocks

Recommended Posts

Guest FirefoxRocks

I was wondering how do I get the HTML source code of another page using PHP.It would be best if the code was in a string, but any format will do as I will search through the text to find certain phrases within.One example is the W3C validator, how is it able to "show source" of another page? (even though it isn't written in PHP)Is there some kind of include code or something?

Link to comment
Share on other sites

One way is to use a function like file_get_contents. file_get_contents and fopen will only work across HTTP if the PHP option allow_url_fopen is enabled. If not, then you can use a socket, which is pretty much manually making a connection to the server and getting the page sort of the same way your browser does it. There is also a library called curl that is built to make things like getting URLs easier than using all of the individual socket functions.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...