lissome
V2EX  ›  问与答

请教 Laravel 怎么提取一个页面中的特定内容(传说中的爬虫?)

  •  
  •   lissome · Jun 3, 2016 · 6170 views
    This topic created in 3659 days ago, the information mentioned may be changed or developed.
    想要提取某个网站的一个页面上的特定内容,页面大体结构就是一些 div 、 table ,需要提取的是一个 table 中的内容, table 有 ID ,要提取的内容也有特定的 class

    因为本身项目是 Laravel ,所以想也用 Laravel 实现,请指教一下思路?有什么包可以用?
    11 replies    2016-06-03 20:05:10 +08:00
    xuxu
        1
    xuxu  
       Jun 3, 2016
    这跟 Laravel 没关系😄
    lissome
        2
    lissome  
    OP
       Jun 3, 2016
    @xuxu 和 PHP 有关系?
    xummerj
        3
    xummerj  
       Jun 3, 2016   ❤️ 1
    这个你可以直接用 curl 获取内容,然后正则或者 PHP Simple HTML DOM 解析;
    还有可以看看这相
    https://github.com/FriendsOfPHP/Goutte
    yangqi
        4
    yangqi  
       Jun 3, 2016   ❤️ 1
    和 laravel 没关系,看看 DomCrawler 这个包
    jugelizi
        5
    jugelizi  
       Jun 3, 2016
    Laravel 什么时候变爬虫了?
    curl 抓取 [snoopy] 然后解析 [simple_html_dom_node]
    lissome
        6
    lissome  
    OP
       Jun 3, 2016
    @yangqi
    @xummerj 谢谢指点

    @jugelizi 并不是要用 Laravel 做爬虫,只是想在现有 Laravel 项目里实现一个这个功能
    terranboy
        7
    terranboy  
       Jun 3, 2016
    goutte 不错 可惜是单线程
    tagtag
        8
    tagtag  
       Jun 3, 2016
    file_get_contents+正则
    Moker
        9
    Moker  
       Jun 3, 2016
    phpQuery 用这个,语法和 JQ 一样 $('table').html()
    icybee
        10
    icybee  
       Jun 3, 2016
    进队列,后台守护进程抓去入库,推荐用各种 mq 实现
    thenbsp
        11
    thenbsp  
       Jun 3, 2016
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3572 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 104ms · UTC 04:54 · PVG 12:54 · LAX 21:54 · JFK 00:54
    ♥ Do have faith in what you're doing.