1

Python の requests ライブラリを使用して、noaa の co-ops API から潮汐情報を取得していますが、エラー 403 禁止された応答が返ってきます。それが違いを生む場合、私はpythonanywhereでpython 2.7を使用しています。これは私のコードです:

headers={'user-agent':'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36',
'From':'iancissel@gmail.com'
}
boston_id='8443970'
url='http://tidesandcurrents.noaa.gov/api/datagetter?date=today&station=8443970&product=high_low&datum=STND&units=english&time_zone=lst&format=json'
r=requests.get(url, headers=headers)
print r
4

0 に答える 0