SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file_get_contents() Question

    Hi all,

    Does anybody know if it is possible to stop file_get_contents() dead in it's tracks when it reaches a certain string to avoid wasting resources? Or do you just have to get the entire file's contents and then extract/remove the parts you don't want?

    I want to extract the textual portion of various web pages using a crawler I have written for my own personal archiving. The info always starts after the same <div id="blahblah"> tag, so this is a useful reference point. Any recommendations for a quicker, less resource-wasting method of achieving this, or am I stuck with file_get_contents() and the substring functions?

    Thanks!

  2. #2
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to check out 'stream_get_line':

    http://www.php.net/manual/en/functio...m-get-line.php


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
  •