私はPythonプログラムを使用してデータを地下にアップロードしていましたが、明確な理由もなく、ある日動作を停止しました。トラブルシューティングを試みるために、次の小さなバージョンを作成しました。
このプログラムは「アップロードに失敗しました」を返します
興味深いことに、パスと Http アドレスを取得してブラウザに入力すると、正常に通過します。これは、パスワードとステーション ID に問題がないことを意味します。送信の成功をブロックする何か他のものがあります。
プログラムは次のとおりです。
import subprocess
import re
import sys
import time
from datetime import datetime
from time import sleep
import httplib
import smbus
import math
stationid = "xxxxxx"
password = "xxxxx"
temperature= 78.2
conn = httplib.HTTPConnection("rtupdate.wunderground.com")
path ="/weatherstation/updateweatherstation.php?ID=" + stationid + "&PASSWORD=" + password + "&dateutc=" + str(datetime.utcnow()) + "&tempf=" + str(temperature) + "&softwaretype=RaspberryPi&action=updateraw&realtime=1&rtfreq=2.5"
conn.request("GET", "path")
print path
sleep(2)
res = conn.getresponse()
# checks whether there was a successful connection (HTTP code 200 and content of page contains "success")
if ((int(res.status) == 200) & ("success" in res.read())):
print "Successful Upload"
print "Temperature F=", temperature
else:
print "%s -- Upload not successful, check username, password, and formating.. Will try again in 6 seconds"
print "TempF =", temperature
応答と理由を出力するコマンドでこれを実行すると、次のようになります。
(404, 'Not Found')
<html><head><title>404 Not Found</title><head><body><h1>Not Found</h1>The requested URL <code>path</code> was not found on this server.<br></body></html
コンポーネントを取る場合:
http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxxxx&PASSWORD=xxxxxx&dateutc=2013-09-07 23:20:30.920773&tempf=78.2&softwaretype=RaspberryPi&action=updateraw&realtime=1&rtfreq=2.5
それをブラウザに入れて実行すると、正常に動作しますか??
ここで何が起こっているのか誰か教えてもらえますか?