我需要一点帮助这里,因为我是新的python,我正在尝试做一个很好的应用程序,可以告诉我我的网站是否关闭,然后发送到twitter。在
class Tweet(webapp.RequestHandler):
def get(self):
import oauth
client = oauth.TwitterClient(TWITTER_CONSUMER_KEY,
TWITTER_CONSUMER_SECRET,
None
)
webstatus = {"status": "this is where the site status need's to be",
"lat": 44.42765100,
"long":26.103172
}
client.make_request('http://twitter.com/statuses/update.json',
token=TWITTER_ACCESS_TOKEN,
secret=TWITTER_ACCESS_TOKEN_SECRET,
additional_params=webstatus,
protected=True,
method='POST'
)
self.response.out.write(webstatus)
def main():
application = webapp.WSGIApplication([('/', Tweet)])
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
现在check网站部分丢失了,所以我对python非常陌生,需要一些帮助
可以检查特定url和答案/错误代码的函数/类的任何想法都可以使用上面的脚本发送到twitter
在上面的脚本中,我需要一些帮助来实现url检查,这是我第一次与python交互。在
如果您想知道,上层类使用https://github.com/mikeknapp/AppEngine-OAuth-Library库
干杯
PS:url检查功能需要基于urlfetch
类,对于googleappengine来说更安全
你可以使用谷歌应用引擎URL FetchAPI。
fetch()函数返回包含HTTP状态代码的Response object。在
只需获取url并使用以下命令检查状态:
检查网站是否存在:
我们只获取给定URL的头并检查web服务器的响应代码。在
更新:最后一行根据Daenyth的备注进行修改。在
相关问题 更多 >
编程相关推荐