SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard Blake Tallos's Avatar
    Join Date
    Jun 2008
    Location
    Cuyahoga Falls, Ohio.
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file_get_content into excel sheet

    I'm trying to view content from a website that is secured. It makes me login into to view the content.

    <?php
    $homepage
    = file_get_contents('http://www.example.com/');
    echo
    $homepage;
    ?>


    What I'm trying to is to be able to view the content without having to view it in the browser.

    I just want to run the script from my desktop. Download the data into an excel sheet.

    Down in the future, I might categorize the information that gets displayed.

    Can someone give me any advice?

    I see it can be done in C#, but something like this be developed in php?


    // prepare the web page we will be asking for HttpWebRequest request = (HttpWebRequest) WebRequest.Create(""); // execute the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // we will read data via the response stream Stream resStream = response.GetResponseStream(); string tempString = null; int count = 0; do { // fill the buffer with data count = resStream.Read(buf, 0, buf.Length); // make sure we read some data if (count != 0) { // translate from bytes to ASCII text tempString = Encoding.ASCII.GetString(buf, 0, count); // continue building the string sb.Append(tempString); } } while (count > 0); // any more data to read?
    Blake Tallos - Software Engineer for Sanctuary
    Software Studio, Inc. C# - Fanatic!
    http://www.sancsoft.com/


  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I think the tool you are seeking is cURL, ie possibly automating the submitting of a POST form with your credentials.

  3. #3
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    220
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    *standard CURL disclaimer*
    Make sure you have permission to scrape the data from the target site; most sites prohibit such activity.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Wizard Blake Tallos's Avatar
    Join Date
    Jun 2008
    Location
    Cuyahoga Falls, Ohio.
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vectorialpx View Post
    Thanks, for the link. How do I actually run the script?
    Blake Tallos - Software Engineer for Sanctuary
    Software Studio, Inc. C# - Fanatic!
    http://www.sancsoft.com/


  6. #6
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    I'm closing this thread as the OP did not clarify their intention regarding scraping. To give you an idea Sitepoint uses lawyers to go after web scrapers that pull material off this site. We don't condone scraping.

    If Blake PMs me @ServerStorm and clears his intentions then I may reopen this thread.
    ictus==""

  7. #7
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by ServerStorm View Post
    I'm closing this thread as the OP did not clarify their intention regarding scraping. To give you an idea Sitepoint uses lawyers to go after web scrapers that pull material off this site. We don't condone scraping.

    If Blake PMs me @ServerStorm and clears his intentions then I may reopen this thread.
    I've reopened the thread, thanks for clarifying your intentions Blake.

    Regards,
    Steve
    ictus==""

  8. #8
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    220
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Blake Tallos View Post
    Thanks, for the link. How do I actually run the script?
    It's in the example: $theContent = get_data('http://davidwalsh.name');


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
  •