Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote file does not finish arriving before script moves on

Status
Not open for further replies.

rlingen

Technical User
Dec 6, 2000
41
CA
I have a small script which calls up a remote dynamically generated webpage, ( examines the resulting HTML code line by line to extract certain information from it that I want to use. (No, I'm not extracting e-mail addresses, but that would be the same sort of thing).

I cycle through a number of calls to the main body of the script, changing the variable "whatever" from a list. The script works fine sometimes, but usually it's on to the next iteration before the first web page has finished arriving. As a result, the information I want hasn't arrived yet, and my script never gets the info I want.

The question is, how can I make the script wait for the entire remotely generated page to arrive before it tries to go through the result line by line? I have tried $file=fopen("$remotefile"); while (!feof($file) {}. I have also tried $line=file($remotefile). Neither of them ends up getting the full file most of the time. I can tell this is the problem because I echoed the file line by line and could see where it cut off the first page and called the next iteration.

Help greatly appreciated.

Roy
 
i'm using the fopen() function when retrieving parts of my page from a remote server, and there's no truncation
so there must be some other bug in you code
post all the loop code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top