0

I want to get the bing result without api , I want to get them direct from bing pages using php. I don't know how to do it.

lamaison
  • 1
  • 2

3 Answers3

0

you can use http requests and pares the results to get what you want you can use regular expressions

example:

$results = file_get_contents("http://www.bing.com/search?q=regular+expressions");

you will find the all HTML content of the page, like you see when click on "view page source"

then apply regex on it to extract the results

AMTourky
  • 1,190
  • 13
  • 25
0

Check out this script: http://www.fromzerotoseo.com/scraping-bing-serp/

in particular the regular expression search which grabs the links:

preg_match_all( '(<div class="sb_tlst">.*<h3>.*<a href="(.*)".*>(.*)</a>.*</h3>.*</div>)siU', $result['EXE'], $matches);

saxman01
  • 288
  • 2
  • 9
0

Just use simple_html_dom and do a simple parse. To get # of bing results, you have to find a specific class called "sb_count". If you need links, change the class by "b_attribution" to get all the links. You can execute your query as follow by looping through the result page using foreach:

include_once 'simple_html_dom.php';
header('Content-Type: text/html; charset=ISO-8859-2'); 

$html = new simple_html_dom();
$param = 'Your query';
$html -> load_file('https://www.bing.com/search?q=' . $param . '&go=Submit&qs=n&form=QBLH&pq=' . $param . '&sc=8-6&sp=-1&sk=&ghc=1&cvid=e3777d60b1f04c90a3d8f08903433c7a');
    foreach ( $html->find('.sb_count') as $post){
        echo  '<p>' . $post . '</p>';
    }
Lio_69
  • 110
  • 9