print_r($ json)返回空白页

时间:2018-11-21 06:28:35

标签: php json web-scraping

我使用json代码,当我运行程序时不显示任何内容。只是银行页面,请帮我解决 这是我的代码

<!DOCTYPE html>
<html>
<head>
    <title>Percobaan</title>
</head>
<body>
    <form method="post" action="#">
        <input type="text" id="scrap" name="scrap" placeholder="Input Hashtag ex: malang">
        <input type="submit" name="submit" value="submit">
    </form>
</body>
</html>
<?php
    if (isset($_POST['scrap'])) {
        $hashtag=$_POST['scrap'];
        $html=file_get_contents("https://mobile.twitter.com/search?q=%23".$hashtag."&src=typeahead_click");
        $json=json_decode($html,true);
        print_r($json);
    }
?>

1 个答案:

答案 0 :(得分:0)

The response is not JSON data, it is just an HTML content, you can only parse the JSON content through the valid JSON data.