Jump to content

Problem with cURL, redirection and frame.


blizzardofozz

Recommended Posts

Hello guys,

 

I have this problem – I want to receive results from external database search using cURL. The form action of the external page leads to .cgi file using POST method. Then redirect happens to a page on other server (HTTP/1.1 302 Moved Temporarily), which I can follow (CURLOPT_FOLLOWLOCATION) but the problem is that the new location page is created using frameset and I cannot follow frame src to receive desired data, which is displayed into one of the frames.

 

If I use GET method:

$cUrl = curl_init();

curl_setopt($cUrl, CURLOPT_URL,’http://address.com?search=whatever’);

curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($cUrl, CURLOPT_FOLLOWLOCATION, 1);

$pageContent = trim(curl_exec($cUrl));

curl_close($cUrl);

echo $pageContent;

then I receive desired page but with no info in it since no POST to form action script was sent.

 

I’m stuck on this for couple of days and I really hope someone to help me on this.

 

Link to comment
https://forums.phpfreaks.com/topic/218322-problem-with-curl-redirection-and-frame/
Share on other sites

Not terribly automation-friendly. Is there an API you can use instead? Are you page scraping something you shouldn't? ;)

 

You could always do a regular expression on the frame source and a second cURL request. Depends what the HTML looks like...

I guess there is no problem to use this form since it’s free to use and doesn’t requires registration. Just want to use it on other site and I will contribute the source. There is nothing hidden there.

 

“You could always do a regular expression on the frame source and a second cURL request.”

You mean to cURL the string $pageContent? How to do that?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.