Forum Moderators: coopster

Message Too Old, No Replies

How to get HTML from external site.

HTML from external site

         

Seraph

6:00 am on Nov 29, 2006 (gmt 0)

10+ Year Member



Ok, so I am kinda new to PHP, I can do some basic functions and stuff, anyway I need to somehow get the HTML source from an external site and use the data from the HTML on my site.

The only problem that the information I need in the HTML is generated from a database on the external site, so the information I need is not in the HTML on my site if I use include, fopen etc.

I was wondering if there was a way to get the HTML source directly or Cache it somehow?

Any help would be appreciated :)

mcavic

7:35 am on Nov 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can get the HTML code using fopen. Your PHP script will see the same thing that any browser sees when it hits the page. You'd probably then need to parse the HTML to find the specific information you're looking for.

swa66

1:26 pm on Nov 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use fopen on remote content.

[php.net...] :

$handle = fopen("http://www.example.com/", "r");

coopster

4:40 pm on Nov 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Seraph.

You can also use file_get_contents(). According to the developers, file_get_contents() [php.net] is the preferred way to read the contents of a file into a string.

eelixduppy

9:38 pm on Nov 29, 2006 (gmt 0)



Also remember to check to see if your php.ini configurations allows this. Check allow_url_fopen [us3.php.net]

Seraph

6:07 am on Nov 30, 2006 (gmt 0)

10+ Year Member



Thanks for all that :) Got it all to work.