cURL / Mailing Lists / curl-users / Single Mail

curl-users

Can NOT obtain web page within html frame: using cookies did not solve problem

From: Wesley Sgroi <Wesley.Sgroi_at_sgroisolutions.com>
Date: Tue, 16 Dec 2003 16:18:52 -0700

I execute the php script shown below but I am not able to retrieve the html
page that I want.
The script correctly posts (using GET) the fields to a form, but only
obtains the html frame.

To try and solve my problem, I read a response on the cURL mailing list to a
similar problem,
however using cookies, as the response had suggested, did not solve my
problem.

When I print the handle information ( print_r(curl_getinfo($ch)) ), the
resulting url: [url] =>
http://www.cars.com/search/used/cc/standard/results/multiple/fs_search_resul
ts.jhtml;jsessionid=FA2O1KKWVTKDRLAZGJBJPTY?aff=national

is the correct page that I want to download (I can paste it into a browser
and see that it does
resolve to the page I want). However, I am just obtaining the html frame.

If you have an idea of how I can solve my problem, or can lead me in the
right direction,
I would greatly appreciate it.

Thank you,
Wesley Sgroi

[code]
----------------------------------------------------------------------------
-----------------------------
<?php
// Download the result of a search at cars.com
// The search is completed by posting (HTTP GET) to their form,
// submitting the form, following redirection, and downloading resulting
page.
// The url it retrieves, based on the 'print_r( curl_getinfo($ch) )' is
correct,
// however, it only download the html frame, and not the page within the
html frame.

$url =
"http://www.cars.com/search/used/cc/standard/process/search.jhtml?mknm=BMW&m
dnm=325&zc=85251&rd=30";

$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_COOKIEJAR, "cook"); //Tried setting cookies based
on
curl_setopt($ch, CURLOPT_COOKIEFILE, "cook"); //a cURL mailing list archive
response.
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out

$result = curl_exec($ch); // run the whole process

print "<pre>";
print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);
print "</pre>";

curl_close($ch);
echo $result;

?>
----------------------------------------------------------------------------
------------------------------
[/code]

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-17