A
A
Alex Ivanov2016-09-20 20:28:02
Parsing
Alex Ivanov, 2016-09-20 20:28:02

How to parse number of pages in search.aol.com?

I'm trying to determine the number of pages of the site through search.aol.com

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://search.aol.com/aol/search?s_chn=prt_btest1-g&q=site%3Ahttps%3A%2F%2Ftoster.ru&s_it=comsearch");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, "http://search.aol.com/");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$strg=curl_exec($ch);
curl_close($ch);
echo $strg;
preg_match("/<div id=\"result-count\">About(.*)results<\/div>/s", $strg,$find);
 
if(preg_match("/Your search returned no results./s", $strg)){$resg=0;} else {$resg=trim($find['1']);}

echo $resg;

As a result, I see this. 09d6971096c04c3180766cac52fff9f3.png
Although the search.aol.com/aol/search?s_chn=prt_btest1-g&q=sit... query itself gives a page for parsing. What could be the problem? The same code on google works great

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rou1997, 2016-09-20
@Rou1997

So there is a difference between a request from a browser and a request from curl, so it’s time for you to master the debugger too, in this case a sniffer, there are quite a few of them - Fiddler, Wireshark, Charles, etc., my advice to you, do not evade this , do not run away from problems, but solve them, otherwise you will remain blind, a programmer without a debugger is blind!

D
Dimonchik, 2016-09-20
@dimonchik2013

Keep in mind - Bing is famous for giving left-handed extradition to wretched nerds

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question