【问题标题】:Get Instagram Info using PHP使用 PHP 获取 Instagram 信息
【发布时间】:2018-04-10 15:14:37
【问题描述】:

我想从 Instagram 帐户获取传记.. 我找到了这个-Getting basic information from Instagram using PHP

$raw = file_get_contents('https://www.instagram.com/USERNAME'); //replace with user
preg_match('/\"followed_by\"\:\s?\{\"count\"\:\s?([0-9]+)/',$raw,$m);
print intval($m[1]);

但是,我真的不知道如何编辑它以获得生物。任何帮助将不胜感激!

【问题讨论】:

    标签: php regex


    【解决方案1】:

    试试这个正则表达式:

    user": ({"biography": ".*?")
    

    完整的 PHP 代码

    $raw = file_get_contents('https://www.instagram.com/USERNAME'); //replace with user
    preg_match('/user": ({"biography": ".*?")/',$raw,$m);
    $array = json_decode($m[1].'}', true);
    echo $array['biography'];
    

    确保您的页面使用utf-8 编码

    <meta charset="utf-8">
    

    【讨论】:

    • 完美运行!但是,例如在-instagram.com/google 和 bio 中,它显示类似 \u2014 的内容,那么,是否可以删除它?谢谢!
    • 非常感谢!它完美地工作! :) 再次感谢! :)
    猜你喜欢
    • 2013-01-03
    • 2014-03-30
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 2012-04-28
    相关资源
    最近更新 更多