|   Source

  • Manually gather data from web or crawling from the web can be a bit tedious
  • some major website like Twitter provide API to access their database
  • some API type is REST , and used by major companies like Twitter.
  • More detailed please follor introduction to data wrangling in MongoDB

  • To get the data from example, http://www.last.fm/api we just need to include this url, and modify the value after the question mark
  • to change in this API, method, api_key, artist and album

  • This is what looks like in JSON, like python dictionary.
  • There's key and value, value could be another JSON

  • Let's go through all the commands
  • First, we specify what the url are
  • Then we input the url to request and get it as text
  • The text itself will be format JSON with some difficulty format to read
  • We can create the parser, or get it automatically with python built itn
  • json.loads will receiving input as string, and treat it as JSON format.
  • the JSON.loads will parsing the JSON data to python dictionary
  • Finally, we can print the data, as well as the value of the key 'artist'