【问题标题】:cURL parse divs class data from other pagescURL 解析来自其他页面的 divs 类数据
【发布时间】:2017-02-14 00:26:17
【问题描述】:

如何解析来自其他网站类的数据?这是我的代码:

public function index()
    {            
        $response = Curl::to('http://www.espn.com/nba/game?gameId=400874421')->get();    
        return dd($response);
    } 

在我需要分数的例子中,什么命令会过滤掉只留下分数的代码?

【问题讨论】:

标签: php laravel parsing curl


【解决方案1】:

有很多 html 解析器可以做到这一点,但我会推荐 Symfony DomCrawler 组件。

http://symfony.com/doc/current/components/dom_crawler.html

$crawler = new Crawler($html);
$crawler = $crawler->filter('.score-class');

【讨论】:

    猜你喜欢
    • 2020-11-03
    • 1970-01-01
    • 2016-06-11
    • 1970-01-01
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 2014-06-05
    • 1970-01-01
    相关资源
    最近更新 更多