472,811 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 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 11586
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"...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.