How do you get HTML of another site using PHP?
Asked
Active
Viewed 938 times
-2
-
3Welcome to StackOverflow. Please see the [FAQ](http://www.stackoverflow.com/faq) for how to ask questions here. – Brian Roach Mar 12 '12 at 21:01
-
Do you own or are the administrator for the other site? If not, what html are you wanting? the underlying code or just to display it in your site? – Brian Mar 12 '12 at 21:02
-
http://stackoverflow.com/search?q=%5Bphp%5D+curl+content – PeeHaa Mar 12 '12 at 21:02
3 Answers
4
file_get_contents("http://www.google.com");
Be warned, the site will see your server as it's client, so for example if you asked for the HTML from IPChicken, it would return the IP of your own server, not of the client who requested the page.

DanRedux
- 9,119
- 6
- 23
- 41
1
If you have url fopen wrappers enabled, it's extremely easy:
$str = file_get_contents('http://...');

ThiefMaster
- 310,957
- 84
- 592
- 636