Page 1 of 1

Extract data from external website using PHP

Posted: Wed Apr 07, 2010 8:44 am
by nixes
Hi all,

I'm looking to find a way to extract data from a table in an external website and store it in an SQL database. Can this be achieved using standard html/php/SQL or will I be required to code this as a seperate tool that runs locally alongside the website?

Any help/advice from people with experience in this field would be greatly appreciated!

Many thanks,
Nick

Re: Extract data from external website using PHP

Posted: Wed Apr 07, 2010 7:04 pm
by minorDemocritus
The first thing that comes to mind is cURL. You'd have to find another library that allows you to pull table data out of the markup, though.

Re: Extract data from external website using PHP

Posted: Sun Apr 11, 2010 7:45 pm
by Jonah Bron
Just use the DOM to parse the HTML with DOMDocument::loadHTML. Then you can extract the table.

Re: Extract data from external website using PHP

Posted: Wed Apr 14, 2010 6:16 pm
by nixes
Hey,

Thanks very much for the suggestions. I'm not massively familiar with DOMDocument and loadHTML. I've done a bit of research and looked in the php manual but still not sure I get it. Could anyone give me a quick description of how it should work in this instance?

Many thanks,
Nick

Re: Extract data from external website using PHP

Posted: Wed Apr 14, 2010 11:04 pm
by omniuni
Well, you could always try file_get_contents($url);