Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Thanked 0 Times in 0 Posts

    Smile Get data from a website

    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.....

  2. #2
    Supreme Master coder!
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,170 Times in 1,161 Posts
    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

  3. #3
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Some say it's everything.
    Thanked 397 Times in 390 Posts
    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() or the cURL library.

    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.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  4. #4
    New Coder
    Join Date
    Feb 2011
    Thanked 0 Times in 0 Posts
    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.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts