Is there a function to which you give the URL of a website and it returns back the source in a string?
Asked
Active
Viewed 119 times
3
-
since I am pretty sure to have provided the correct answer, could you please accept my answer **or** edit your question to point out why my answer is not solving your problem. – Gordon Nov 01 '10 at 13:04
-
1Your answer solved the question yes, but not the exact answer which I was looking for. I was parsing an XML file and your method brought back only the contents in the XML file without the tags or anything. However, I was able to do that through XML reader. Thanks for your help :) – Ahmad Farid Nov 01 '10 at 15:10
1 Answers
2
Yes,
file_get_contents
— Reads entire file into a string. A URL can be used as a filename with this function if the fopen wrappers have been enabled.
Example:
file_get_contents('https://www.example.com');
Otherwise cURL and HTTP will do.
If you want to parse the contents on the page, you will likely want use a DOM Parser instead.