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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can fopen or fread be blocked?

Status
Not open for further replies.

mwpclark

Programmer
Mar 14, 2005
59
US
I have 2 scripts

The first one works fine with google.com (gets the text anyway) but does not grab anything from switchboard.com.

Code:
$GrabURL = "[URL unfurl="true"]http://www.DOMAIN.com";[/URL]  //-  Complete URL Of The Page You're Grabbing From!
$GrabStart = "<html>";  //- HTML Code To Start Grab. Must Be A Unique Bit Of Code!
$GrabEnd = "</html>";  //- HTML Code To End Grab. Must Be A Unique Bit Of Code!

$OpenFile = fopen("$GrabURL", "r"); //- DO NOT CHANGE
$RetrieveFile = fread($OpenFile, 200000);  //- Reduce This To Save Memory
$GrabData = eregi("$GrabStart(.*)$GrabEnd", $RetrieveFile, $DataPrint);
// $DataPrint[1] = str_replace("", "", $DataPrint[1]);   //- Un-Comment This Line for "Replace" purposes!
// $DataPrint[1] = str_replace("", "", $DataPrint[1]);   //- Un-Comment This Line for "Replace" purposes!
fclose($OpenFile); //- DO NOT CHANGE
echo $DataPrint[1]; //- DO NOT CHANGE


This script works just fine:

Code:
include("[URL unfurl="true"]http://www.switchboard.com");[/URL]


Is it possible that fopen or fread is blocked by switchboard.com? If so, is there any workaround?

Thanks, Mike
 
It's certainly possible.


A content filter on your network could be blocking access to one but not the other.

DNS problems could be blocking it.

It's possible, too, I guess, that the server at switchboard.com doesn't like the web client identifier PHP sends and is cutting you off.


I don't know how much access you have to the server which is running PHP, but if you can, try accessing switchboard.com from another application on the server.



Want the best answers? Ask the best questions! TANSTAAFL!
 
I have full access to the server, and I use a perl spider to access switchboard.com all the time.
 
How are you testing that nothing is being fetched? If I change your posted code, replacing:

echo $DataPrint[1]; //- DO NOT CHANGE

with

echo $RetrieveFile; //- DO NOT CHANGE


I get content. It looks to me like it's your eregi() invocation that's causing the problem.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top