Crawling Google Search with PHP

前端 未结 3 847
暖寄归人
暖寄归人 2021-02-02 04:52

I trying to get my head around how to fetch Google search results with PHP or JavaScript. I know it has been possible before but now I can\'t find a way.

I am trying to

3条回答
  •  再見小時候
    2021-02-02 05:27

    I did it earlier. Generate the html contents by making https://www.google.co.in/search?hl=en&output=search&q=india http request, now parse specific tags using the htmldom php library. You can parse the content of result page using PHP SIMPLE HTML DOM

    DEMO : Below code will give you title of all the result :

    find('li[class=g]') as $element) {
        foreach($element->find('h3[class=r]') as $h3) 
        {
            $title[$i] = '

    '.$h3->plaintext.'

    ' ; } $i++; } print_r($title); ?>

提交回复
热议问题