Welcome to WebmasterWorld Guest from 34.236.170.48

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Unable to get source code for external websites

Probably need to reconfigure something as code is pretty simple

     
4:39 pm on Dec 20, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


I have Sokkit installed on a windows xp machine. I want to parse the html code of an external website but it doesn't look like php is connecting to any website I try. Here's the code I'm using.

$html=strtolower(implode('',file("http://www.yahoo.com")));
echo $html;

Is there some kind of configuration I have to make? The computer is on a network which is protected by a firewall, would that also have anything to do with it?

Thanks.

12:11 am on Dec 21, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2003
posts:775
votes: 0


Never heard of Sokkit before. Why pay though when you can get XAMPP [apachefriends.org] for free?

Anyway, you might have to change the fopen_wrappers setting [ca.php.net]. I find it so much nicer to use file_get_contents [ca.php.net].

Tim

7:30 pm on Dec 21, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


I tried file_get_contents() instead of file() and that didn't work. Also within php.ini allow_url_fopen was set to "on" and I changed it to "1" since that's what it shows here [ca.php.net...] but the script still isn't retreiving the html code.

Any other ideas?

10:19 pm on Dec 21, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


Are you receiving any errors? Do you have error_reporting() turned up?
10:40 pm on Dec 21, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


I have error reporting turned on and using the following code I didn't receive any error messages, but I also received no output:

$url= 'http://www.msn.com';
$conn = fopen($url, "r");
$html = file_get_contents($url);
fclose($conn);
echo "HTML is:<BR><BR> $html";
die();

<added>
When I launch internet explorer I have to log in through a Novell login page before I can start browsing web pages. Is there somewhere I need to specify this username and password within php.ini or something?
</added>

11:07 pm on Dec 21, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


That certainly sounds like your issue then. It sounds to me like you may very well have an internal network issue to overcome first.

With file_get_contents() you do not need to fopen() and fclose(), by the way.

11:23 pm on Dec 21, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


So can anyone here help with this or do I need to contact our IT department? I'm just wondering if there's something in php.ini or similar file that I can edit to fix the issue or if it's something I dont have control over. just knowing it's a network issue doesnt help much, I'd like to get a better understanding of how to go about fixing it.

Thanks for the replies so far.

7:25 pm on Dec 22, 2005 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


You are correct in that this is a very simple operation and should be working just fine. If no errors are showing up, there isn't anything you can possibly do in the config to get it working beyond where it is at. I would check with the IT folks to see if they are blocking or if any errors are showing up first. If the server is running internally, try retrieving an internal web page first, unless of course you have to log in to get to that server too.
7:43 pm on Dec 22, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


for 100% same operation, i use 100% different code. you might want to give it a try as well.

ob_start();
$page="http://wheretograbhtmlcodefrom"
include $page;
$data=ob_get_contents();
ob_clean();

echo $data;

;)

8:10 pm on Dec 22, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


Yeah I have 4 different coding examples that all work when I try grabbing the HTML source code of other pages on the internal website.

So while the code is working, PHP is unable to retreive HTML source code from websites outside of the network.

Any idea how to get Novell to let PHP out?

8:17 pm on Dec 22, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


Although, this could be a vague fluke but this could be it as well.

Your Php Parser may be blocked out-of-network access by your firewall and whenever it tries to grab html from an external website your firewall blocks it?

8:30 pm on Dec 22, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 28, 2003
posts:492
votes: 2


Yeah isn't that what Novell is? Either way, how do I open up the firewall to let PHP through? When browsing the internet I go to a Novell login screen so I can access the web. How do I get PHP to do the same thing?
11:58 pm on Dec 22, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2003
posts:775
votes: 0


I not sure but I think a proxy might help in this case.
[whitefyre.com...]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members