SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot GWild's Avatar
    Join Date
    May 2005
    Location
    Colorado
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Pull Query Data via php Script?

    Hello.

    I am working in a php 5.1.12 environment.

    Does php contain functionality which will allow me to 'pull' query data from a website and capture it into something like a data stream?

    I want to write a script, for example, that could take a URI/Query string and retrieve the resulting query data output so I can capture it, say, to a string (or possibly array) for further manipulation.

    There are about 15 sites I need to query, and I'm trying to avoid visiting each site and having to do browser output copying into a spreadsheet. I want to retrieve the data programatically and remotely.

    Any help is appreciated.
    Lang ist der weg und hart,
    das aus der hoelle fuehrt auf zum licht.


    My Site

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean that you want to fetch the database rows from another server to your server? Or simply like this:
    PHP Code:
    $siteString file_get_contents("http://www.google.com/");
    echo 
    $siteString
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you trying to to just fetch a page, (html) or directly accessing a database. For the first method there are many different functions. Which one to use would be based on things you need to do. Like, (do you need to login, is a SSL connection being used). If those are things that you need to do then have a look at the PHP CURL FUNCTIONS, or you can use the Network Functions (fsockopen). But for simple fetching, the best method is using the function file_get_contents ();

  4. #4
    SitePoint Zealot GWild's Avatar
    Join Date
    May 2005
    Location
    Colorado
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the responses.

    I'm trying to capture something along the lines of:

    htt://somesite.com?qparam1=x&qparam2=y&qparam3=z


    and 'grab' the query results. I don't have access to the actual database.

    I suppose a better way to phrase the question is to ask if I can actually submit the request (page with query string) and capture the returned results (web page)?


    Thanks.
    Lang ist der weg und hart,
    das aus der hoelle fuehrt auf zum licht.


    My Site

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can parse and find the actual lines from the whole returned HTML page then go for file_get_contents("htt://somesite.com?qparam1=x&qparam2=y&qparam3=z") as i have already given a short example.

    Other if you are well known about the parameters and page of the second server then you can use AJAX or CURL functions too. Choose one for the best for you.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Evangelist speda1's Avatar
    Join Date
    Jan 2002
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would use CURL.

  8. #8
    SitePoint Zealot GWild's Avatar
    Join Date
    May 2005
    Location
    Colorado
    Posts
    159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by speda1 View Post
    I would use CURL.
    I'll look at both CURL and file_get_contents()

    I appreciate the responses.
    Lang ist der weg und hart,
    das aus der hoelle fuehrt auf zum licht.


    My Site


Bookmarks

Posting Permissions

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