我将如何使用 PHP 和 MySQL 抓取此 JSON 信息? [英] How would I scrape this JSON info using PHP and MySQL?
问题描述
这是我试图分解到数据库中的信息.我将仅将它用于我自己的用途来分析统计数据等等.我一直在用 Excel 手动执行此操作,但我想在将来为自己节省一些工作.
Here's the info I'm trying to break up into a database. I'm going to be using this only for my own use to analyse statistics and all that. I have been manually doing it with Excel but I'd like to save myself some work in future.
网址是:http://fantasy.premierleague.com/web/api/元素/537/
知道如何抓取该信息或轻松将其转换为 Excel 格式吗?我知道一点 php 和 mysql,但对 JSON 一无所知,对抓取也知之甚少(我尝试弄乱 SIMPLE_HTML_DOM).
Any idea how to scrape that info or easily convert it to excel format? I know a bit of php and mysql, but nothing about JSON and very little about scraping (I tried messing with SIMPLE_HTML_DOM).
推荐答案
您需要在 PHP 中对数据进行 JSON_decode.
You need to JSON_decode the data in PHP.
$obj = JSON_decode($mydata));
print_r($obj);
给您的额外信息:http://php.net/manual/en/function.json-decode.php
这篇关于我将如何使用 PHP 和 MySQL 抓取此 JSON 信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!