473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP fopen file_get_contents AND javascript top.location

BPG
Hi There,

I'm running into a little problem using "file_get_contents".
When i try to open a page just using my browser i can see the consents
of the page, however, when i try to open this same page with
file_get_contents all i get is:

<html><script language="javascript">top.location='/default.asp?
id=10script';></html>

It's the exact same URL as the one i open in my browser, is there a
way to get around this so that I can read the file using php?

Thnaks in advance,
BPG

Sep 3 '07 #1
3 4388
On Mon, 03 Sep 2007 10:32:05 +0200, BPG <ma**@bpg.nuwrote:
Hi There,

I'm running into a little problem using "file_get_contents".
When i try to open a page just using my browser i can see the consents
of the page, however, when i try to open this same page with
file_get_contents all i get is:

<html><script language="javascript">top.location='/default.asp?
id=10script';></html>

It's the exact same URL as the one i open in my browser,
Keep an eye on the addressbar... It will not be the same.. after a second.
is there a
way to get around this so that I can read the file using php?
Not automatically, no. This would require a javascript engine somewhere.
You can do this by either fetching to page through a UA on the server
itself which is javascript capable, or by examening the javascript 'by
hand' and fix things.

Quick fix in this case: regardless of what your original url might be,
fetch http://<the domain in question>/default.asp?id=10script
--
Rik Wasmus
Sep 3 '07 #2
BPG wrote:
Hi There,

I'm running into a little problem using "file_get_contents".
When i try to open a page just using my browser i can see the consents
of the page, however, when i try to open this same page with
file_get_contents all i get is:

<html><script language="javascript">top.location='/default.asp?
id=10script';></html>

It's the exact same URL as the one i open in my browser, is there a
way to get around this so that I can read the file using php?

Thnaks in advance,
BPG
Some sites require you to send the user-agent request header.
Try using curl <http://php.net/curlinstead.

Sep 3 '07 #3
BPG
I did try to fetch http://<the domain in question>/default.asp?id=10,
this didn't work be course the "/default.asp?id=10" doesn't contain
the info i need.

However using curl did solve the problem, i didn't even know this
option in PHP, it's great for me it also makes me able to open some
other pages with didn't open before :)

Thanks you both for the help! :)

Sep 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: typingcat | last post by:
Is it possible to read another web page in PHP? If is ASP.NET, the code would be ------------ WebRequest req=WebRequest.Create("http://www.microsoft.com"); WebResponse res=req.GetResponse();...
7
by: Justin Koivisto | last post by:
system: php 4.4.2 windows 2003 server apache 1.3.x problem: scripts don't work :-P description:
5
by: pieterprovoost | last post by:
Hi, Can anyone tell me why going to http://www.algaebase.org/DistributionResponse.lasso?currentMethod=distro&sk=20&-session=abv3:D5C1E5F111d2e05040XVy1A0A54A yields results, while the same page...
1
by: Cleverbum | last post by:
I'm trying to write a script which downloads information from a number of websites analyses it and shows some results. The problem I'm having is that some sites seem to work perfectly while others...
6
by: rfhurley | last post by:
I'm a newbie at this... I'm trying to run a PHP script from the W3C PHP tutorial, and the example shows the following code: <html> <body> <?php $file=fopen("welcome.txt","r"); ?>
2
by: Giorgio Sam | last post by:
Hello there, WEIRD...fopen couldn't open any http file while it's working fine with any local file. I've tried the following: ________________________________________________________ 1. ...
15
by: joker197cinque | last post by:
I'm trying to fopen a file this way: $handle = fopen("http://localhost/test.html", "r"); but tha page remains "loading .." for 30 seconds and then goes in timeout. However I can open that...
11
AutumnsDecay
by: AutumnsDecay | last post by:
Hey there. I've been implimenting FCKEditor into my clients websites so they can update the text and pictures on their own. The way it is currently setup is that you need to 'login' to gain...
3
by: jeddiki | last post by:
Out of these, which one do you use most and why ? fsockopen, curl, fopen, file_get_contents,
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.