Welcome to WebmasterWorld Guest from 54.158.143.40

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Grab html from remote webpage and post it to mysql database

   
7:30 pm on Sep 28, 2006 (gmt 0)

5+ Year Member



Hi all.

I'm trying to create a webpage where I can input a URL to a form. The page will then grab the html of the URL and put it in a mysql database.

I'de like to just make it clear that I am not at all trying to steal content. I'm trying to build a small searchable directory of websites. I need the html to search through.

I'm doing this for a friend, and unfortunately his site is on a linus server, so this particular part of the site has to be done in php - which I do not know...

Any help will be greatly appreciated. I really hope someone can help me with this.
thanks.

8:45 pm on Sep 28, 2006 (gmt 0)

5+ Year Member



I'd be able to do this in asp with an HTTP get - but on a linux server, this is a no go...
It must be possible to put all the html into a variable and then put it in the data base. I just need to make this one page in php - the rest I can figure out by myself how to do in asp.
I can do the database bit, but I have no idea how to get the html from the remote webpage into a variable.
Come on folks - show me why php is better than asp ;)
8:48 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Just use fopen [php.net]. It can open URLs in the same manner you would open a local file.
9:25 pm on Sep 28, 2006 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



>>>It can open URLs in the same manner you would open a local file.

This is only if allow_url_fopen [us3.php.net] is enabled. If not, you must set it to 1 in your php.ini file.

Also, file_get_contents [us3.php.net] is another way to get your content.

Best of luck!

10:38 pm on Sep 28, 2006 (gmt 0)

5+ Year Member



I use file [us2.php.net] and fsockopen [us2.php.net] to get RSS and XML files.
5:10 pm on Sep 29, 2006 (gmt 0)

5+ Year Member



Thank you very much for your help. It got me well on the way :-)