[PYTHON] Flow memo when getting json data with urllib

Reference page

http://docs.python.jp/2/howto/urllib2.html

point

If you do not pass the data argument, urllib2 makes use of the GET request.

That means POST if you pass an argument

sample

import urllib import urllib2 import json

url = 'http://api.hoge.json' params = { 'status': 1 } data = urllib.urlencode(params) req = urllib2.Request(url, data) response = urllib2.urlopen(req) json_acceptable_string = response.read().replace("'", """) data = json.loads(json_acceptable_string)

Recommended Posts

Flow memo when getting json data with urllib
Data is missing when getting stock price data with Pandas-datareader
Read json data with python
Merge JSON format data with Ansible
Convert Excel data to JSON with python
A memo when creating a python environment with miniconda
Materials to read when getting started with Python
"Getting stock price time series data from k-db.com with Python" Program environment creation memo
Be careful when reading data with pandas (specify dtype)
Materials to read when getting started with Apache Beam