I'm trying to get the Bing search count result using PHP cURL.
I tried cURL but the response is not returning any result. It is returning only the header and footer of the Bing search page.
My code:
$url = "https://www.bing.com/search?q=site:mysite.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
sleep(10);
$response = curl_exec($ch);
curl_close($ch);
Then I tried with Python with sleep.
url = "https://www.bing.com/search?q=site:mysite.com";
browser.get(url)
time.sleep(1)
print(browser.page_source) # results
And this returned the HTML with Bing search result count.
......
<span class="sb_count" data-bm="4">465 results</span>
.....
Similar to Python how can I sleep PHP cURL execution in between for few seconds and get the search result.
Any help would be appreciated. Thanks in advance.

cURL is returned fastly before the cURLed url prepares the result...this doesn't make any sense. cURL sends a HTTP request, and then it waits for the response. cURL won't return a response until the remote server sends back some data. That is a hard fact. So maybe explain to us what response you're seeing, and what response you expected? I'm going to hazard a guess that the remote site uses some JavaScript/AJAX to load extra content, and you've forgotten about the fact that cURL cannot execute Javascript. so all you get back is the HTML returned by the initial basic HTTP request.browservariable? Does it represent a headless browser? If so it might have the capability to execute javascript, which may be the difference here. I don't know but I'd guess there is a headless browser library for php somewhere which you could try