dongmou3615 2019-02-26 11:51
浏览 48

PHP - 获取谷歌显示的价格

I would like to recover all price from Google search in a PHP file.

Exemple of price search :

file_get_contents doesn't work and i've to use CURL like in this topic :

PHP file_get_contents error 503

Now i dunno how to create next of script.

I guess I have to create a loop and use the function preg_match to keep only what i need.

It is right ? Can i've any exemple ?

Here is the beginning of my script :

            $url = "";

            function curl_get_file_contents($URL) {
                $c = curl_init();
                curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($c, CURLOPT_URL, $URL);
                $contents = curl_exec($c);

                if ($contents) return $contents;
                else return FALSE;

                foreach ($variable as $key => $value) {

                    echo $result;
  • 写回答

1条回答 默认 最新

  • dongzaliang4492 2019-02-26 12:04

    This will not work reliably. Google search is quite sensitive to scraping and quickly starts to respond with request to verify captcha when it suspects automated access.

    I would recommend to look into a better source for information you need, otherwise you just risk burning time on writing code that won't run because you can't consistently get your data in first place.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 w10部分软件不能联网
  • ¥15 关于安装hbase的问题(操作系统-windows)
  • ¥15 cadence617版本,如何做一个参数可调的反相器
  • ¥15 novnc连接pve虚拟机报错安全协议不支持262
  • ¥15 设备精度0.03给多少公差能达到CPK1.33
  • ¥15 qt+ffmpeg报错non-existing PPS 0 referenced
  • ¥15 FOC simulink
  • ¥50 MacOS 使用虚拟机安装k8s
  • ¥20 玩游戏gpu和cpu利用率特别低,玩游戏卡顿
  • ¥25 oracle中的正则匹配