-2

How do you get HTML of another site using PHP?

Christofer Eliasson
  • 32,939
  • 7
  • 74
  • 103
officegunner
  • 97
  • 1
  • 9
  • 3
    Welcome 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 Answers3

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
0

You ave to use dom parser for parsing html. Here is php dom parser example and how to use it: link

or here

link

Community
  • 1
  • 1
Elbek
  • 3,434
  • 6
  • 37
  • 49