How To Rotate Links From 2 Remote Websites?

Ladies & Gentlemen,

What would be the cURL snippet that keyword searches 2 searchengines and displays their results like so:

ranked 1st link (on google)
ranked 1st link (on yahoo)
ranked 2nd link (on google)
ranked 2nd link (on yahoo)

In short, I want the cURL/php to first list the 1st ranked link found on google, then the 1st ranked link found on yahoo and then the 2nd ranked link found on google and then the 2nd ranked link found on yahoo.

Quite frankly, I don’t have any clue how to code this apart from what you see below. Hence, no proper code presented here.
Any code sample to get me started is appreciated. I will then try building from then on.


<?php

/*
ERROR HANDLING
*/
declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/search?q=ice+cream&oq=ice+cream&aqs=chrome..69i57.2289j0j7&sourceid=chrome&ie=UTF-8");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$curl_result = curl_exec($ch);
echo $curl_result;
		
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=ice+cream&fr=yfp-t&fp=1&toggle=1&cop=mss&ei=UTF-8");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$curl_result = curl_exec($ch);
echo $curl_result;

?>

I get no error but I get a complete blank page. Strange!

Thanks!

be more verbose

var_dump(curl_errno($ch));
var_dump(curl_error($ch));
var_dump(curl_getinfo($ch));
var_dump($curl_result);

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.