473,386 Members | 1,606 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,386 software developers and data experts.

Can php emulate internet explorer browser requests ?

I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?
Jul 17 '05 #1
6 11627
Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.


Tricky.

You should get *something*. The PHP installation may be cobbled if it's not
on a dedicated machine.

The standard system can't cope with cookies, redirects and javascript.
Snoopy (available at sourceforge) can do a lot (but IIRC not javascript)

HTH

C.
Jul 17 '05 #2
Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?


http://pear.php.net/manual/en/packag...ttp-client.php
Jul 17 '05 #3
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

On 26.04.2005 14:38, Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?

Jul 17 '05 #4
If only it was that easy Hannes :)

The is is the url of one the the pages

http://www.betfair.com/betting/BetsM...do?=1062510579

Compare the response from a browser requesting that page and the
file_contents_gets or fopen requests. I think I'll have to check out
the pear scripts as none of the curl ones I tried seemed to work
either

Hannes Dorbath <li***@theendofthetunnel.de> wrote in message news:<42***********************@news.disputo.net>. ..
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

Jul 17 '05 #5
that page doesn't work for me even in IE. there is some timeout msg in
the js..

however, it's easy anyway. grab

http://www.blunck.info/iehttpheaders.html

surf that page, take the requerst header, use

fwrite(fsockopen('that.strange.host', 80), $headers);

in case of https use fsockopen('ssl://that.strange.host', 443);

done.

On 27.04.2005 10:43, Captain wrote:
If only it was that easy Hannes :)

The is is the url of one the the pages

http://www.betfair.com/betting/BetsM...do?=1062510579

Compare the response from a browser requesting that page and the
file_contents_gets or fopen requests. I think I'll have to check out
the pear scripts as none of the curl ones I tried seemed to work
either

Hannes Dorbath <li***@theendofthetunnel.de> wrote in message news:<42***********************@news.disputo.net>. ..
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

Jul 17 '05 #6
NC
Captain wrote:

I'm looking to post data (GET) to a site using a php script -
commands like fopen() file_content_gets won't retrieve the data.
I assume this is because the server is expecting the request
to come from a browser.
Assumptions won't do. Unless you know what the problem is, you
can't fix it. You need to look at HTTP headers that are being
exchanged between the browser and the server. It is possible
the server sends cookies and expects the client to have them.
What do I need to do to make sure the request appears to be
coming form a browser, and what would be the best way of
posting the data ? cURL pear fsockopen ?
I have worked successfully with both fsockopen() and cURL.
If it's too hard or impossible for php I guess I'll have to
port my code over to VB .Net as I assume that program uses
the IE libraries anyway ?


Since at this point you don't know what your problem is,
switching to another programming language is premature.

Cheers,
NC

Jul 17 '05 #7

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

Similar topics

2
by: Raymond H. | last post by:
Hello, I create a vb4 project which can also naviger on Internet via the WebBrowser control which I put on my form. My question is: if this program is installed on a station having already...
8
by: Joseph Haig | last post by:
Can someone please help me with a problem I have with using alpha transparency in Internet Explorer. I use a php script to determine the browser and if it is found to be Internet Explorer, the...
12
by: tomasio | last post by:
Dear Group, I managed to simulate framelike behaviour in mozilla-based browsers by now, but it doesn't work out with Internet Explorer 6. Could someone glance through the code on the...
7
by: R0bert Nev1lle | last post by:
Internet Explorer always presents me with a challenge (partial repost). The current issue involves emulating max-width in IE using the technique described by Svend Tofte. ...
5
by: Adam Stirk | last post by:
Hi, I have a application that I need to create multiple new "iexplore.exe" processes (show more than once in taskmanger) and control them using the shdocvw/mshtml. I am able control Internet...
3
by: Raterus | last post by:
Anyone know how I can figure out the figure out the response.redirect trail a browser goes through when I'm using response.redirect on the server. Right now Internet Explorer just automatically...
6
by: Sandy | last post by:
Hello - I have a little application that I would like to have an exit button on that closes my web application and closes Internet Explorer. What is the code that will do that? Any help...
6
by: pradeep_TP | last post by:
I am facing a strange problem with my web site. Afer reinstalling the web application on the web server, I am getting a dialog box for each page. The dialog box has the following information. ...
1
by: dearprasan | last post by:
I have a custom browser application built in C#. I want to access the Internet Explorer's Cache to display contents on this custom browser application. For example: If the user types "www.msn.com"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.