In this article, we will learn how to get the contents of a web page, RSS feed, or XML file into a string variable. This can be used in various ways to get information from a website or RSS feed. For example, you could use this variable to get the title of a web page or RSS feed, the date of a given RSS feed, or even the text of an XML file.
You can go with the really short method:
The only problem with that method is that some web hosts have url access blocked in the file methods, for security reasons. You may be able to use this workaround method instead:
$str = file_get_contents($url);
You should now have the contents of the website in a string variable. Note that this doesn’t pull down the supporting files such as javascript or CSS. You will have to further parse the page and retrieve those seperately if you need the whole thing.