12
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pepperのpythonでHTTP GETしてJSONパースするサンプル

Posted at

HTTP Getボックスの作成をもとに作ってみました。

APIはこの天気APIです。
http://weather.livedoor.com/forecast/webservice/json/v1?city=200010

class MyClass(GeneratedClass):
    def __init__(self):
        GeneratedClass.__init__(self)

    def onLoad(self):
        #put initialization code here
        pass

    def onUnload(self):
        #put clean-up code here
        pass

    def onInput_onStart(self, url):
        import urllib2, json
        api = "http://weather.livedoor.com/forecast/webservice/json/v1?city=200010"
        r = urllib2.urlopen(api)
        root = json.loads(r.read())
        self.onStopped(root['title'].encode('utf8'))

12
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?