duanchuopi2298 2018-10-27 05:06
浏览 15

PHP#FUT得到价格

I have problem. I want get price player, using the preg_match but I get "-".

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.futbin.com/19/player/353/Sergio%20Busquets/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
curl_setopt($ch, CURLOPT_USERAGENT, "Google Bot");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$downloaded_page = curl_exec($ch);
curl_close($ch);
preg_match_all('/<div\s+class="bin_price lbin">(.*)<\/div>/', $downloaded_page, $title); 
echo "<pre>";
foreach ($title[1] as $realtitle) {
    echo $realtitle . "
";
}
echo "</pre>";
  • 写回答

1条回答 默认 最新

  • dongpaozhi5734 2018-10-27 05:36
    关注

    If you check the source code of the page you will see that why are you collecting this "-"

    <div class="bin_price lbin">
       <span class="price_big_right">
          <span id="ps-lowest-1">-</span>
       </span>
    </div>
    

    You won't be able to perform that task by CURL because the values are loaded asynchronous and curl gets the exactly source code that you can view by right clicking the browser and selecting view source code (this is not the same as using the chrome dock or firebug (f12).

    The solution for that is to use an browser automation software that can be programmed by any compiled language (python, java, c++). I recommend selenium web browser.

    https://www.seleniumhq.org/docs/

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用