【问题标题】:Trying to scrape content with php试图用 php 抓取内容
【发布时间】:2012-11-15 16:51:34
【问题描述】:

我正在尝试从以下位置获取 Facebook 页面 ID:

http://fanpagelist.com/category/top_users/view/list/sort/fans/page1

大约有 25 个,可以通过/like_box.php?id=89562268312 模式查看源代码来找到它们。 https://graph.facebook.com/89562268312/picture

<?php 
    $page = file_get_contents('http://fanpagelist.com/category/top_users/view/list/sort/fans/page1');
    preg_match_all('graph.facebook.com,picture', $page, $result, PREG_SET_ORDER);
    foreach ($result as $row) {
        echo "<p><b>$row[1]</b> $row[2]</p>\n";
    }
?>

问题是我不是要刮标签而是要刮图案。

【问题讨论】:

标签: php regex


【解决方案1】:

你应该擅长:

preg_match_all('#(?:(?<=\bhref="/like_box\.php\?id=)|' .
                '(?<=\bsrc="https://graph\.facebook\.com/))\d+#i',
                $page, $result, PREG_PATTERN_ORDER);

this demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-20
    • 1970-01-01
    • 2012-09-08
    • 2016-02-14
    相关资源
    最近更新 更多