...

View Full Version : Get data from a website



murugavelb
11-14-2011, 03:24 PM
I need to grab the data from a website and display it on my .PHP page...........

For instance, get the STOCK MARKET details from a STOCK MARKET WEBSITE and i want to display

those STOCK DETAILS in my .PHP page.....

mlseim
11-14-2011, 04:15 PM
Give us the URL to that stock website so we can see how they format their HTML.
If you have to log-in, that's going to be a problem

Rowsdower!
11-14-2011, 04:20 PM
First step would be to see if the website in question has an API for this type of thing (many do). If so, then use that API in whatever way you need. Sometimes they offer a JSON (javascript) API for such things and other times it is XML. You might simply be able to call it in with javascript. If you're dedicated to getting the data without javascript then you're looking at either file_get_contents() (http://php.net/manual/en/function.file-get-contents.php) or the cURL library (http://us2.php.net/manual/en/book.curl.php).

If there is no API, you can try simple screen-scraping of the entire target page (I would recommend caching and using a database for this), again via either file_get_contents() or the cURL library. Then you will need a good way to match the right data pattern from their source code in order to display the desired data (if they use element IDs then this becomes a bit easier, but it's never too much fun to do this). Just make sure that this isn't against their terms of service or you might have some trouble down the road.

amof
11-15-2011, 04:12 PM
I would use a combination of Curl and Simple html dom parser:

Use curl to get to post/get etc and Simple html dom parser to parse through the results.

http://simplehtmldom.sourceforge.net/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum