LoginSignup
0
0

More than 5 years have passed since last update.

Requests使ってみたメモ

Posted at

Requestsを使った時のメモ

コード

import requests

url = 'http://www.ekidata.jp/api/s/1130224.xml'
res = requests.get(url)

# 日本語文字化け対応
res.encoding = res.apparent_encoding

print(res.text)

出力結果

<?xml version="1.0" encoding="UTF-8"?>
<ekidata version="ekidata.jp station api 1.0">
    <station>
        <pref_cd>13</pref_cd>
        <line_cd>11302</line_cd>
        <line_name>JR山手線</line_name>
        <station_cd>1130224</station_cd>
        <station_g_cd>1130101</station_g_cd>
        <station_name>東京</station_name>
        <lon>139.766103</lon>
        <lat>35.681391</lat>
    </station>
</ekidata>
0
0
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
0
0