弄过GAE的帮帮忙.

Y.A.K.E 2012-11-04 12:55:49

import sys, urllib2

headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
req = urllib2.Request("http://www.yge.me", headers=headers)
content = urllib2.urlopen(req).read()
type = sys.getfilesystemencoding()
print content.decode("UTF-8").encode(type)


我PY程序大概如上.
功能就是访问指定网页.

我本地执行这个PY脚本是可以无错执行的.

但是这个上传到GAE的时候报错.
2012-11-04 12:35:51,535 ERROR appcfg.py:2202 An error occurred processing file '': <urlopen error [Errno 10060] >. Aborting. 
Traceback (most recent call last):
File "F:\Program Files (x86)\Google\google_appengine\appcfg.py", line 171, in <module>
run_file(__file__, globals())
File "F:\Program Files (x86)\Google\google_appengine\appcfg.py", line 167, in run_file
execfile(script_path, globals_)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 4322, in <module>
main(sys.argv)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 4313, in main
result = AppCfgApp(argv).Run()
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2599, in Run
self.action(self)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 4048, in __call__
return method()
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3065, in Update
self.UpdateVersion(rpcserver, self.basepath, appyaml)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3047, in UpdateVersion
lambda path: self.opener(os.path.join(basepath, path), 'rb'))
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2172, in DoUpload
self.resource_limits = GetResourceLimits(self.rpcserver, self.config)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 357, in GetResourceLimits
resource_limits.update(GetRemoteResourceLimits(rpcserver, config))
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 328, in GetRemoteResourceLimits
version=config.version)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 403, in Send
self._Authenticate()
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 543, in _Authenticate
super(HttpRpcServer, self)._Authenticate()
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 342, in _Authenticate
self._GetAuthCookie(auth_token)
File "F:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 268, in _GetAuthCookie
response = self.opener.open(req)
File "F:\Python27\lib\urllib2.py", line 400, in open
response = self._open(req, data)
File "F:\Python27\lib\urllib2.py", line 418, in _open
'_open', req)
File "F:\Python27\lib\urllib2.py", line 378, in _call_chain
result = func(*args)
File "F:\Python27\lib\urllib2.py", line 1215, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "F:\Program Files (x86)\Google\google_appengine\lib\fancy_urllib\fancy_urllib\__init__.py", line 383, in do_open
raise url_error
urllib2.URLError: <urlopen error [Errno 10060] >
2012-11-04 12:35:51 (Process exited with code 1)


附上corn.yaml

cron:
- description: test
url: main.py #好像这里是错的
schedule: every 10 minutes #不知道指定时间写法


app.yaml

application: ***** #我的GAE id
version: 1
runtime: python27
api_version: 1
threadsafe: yes


告诉我怎么修改.最好是帮我修改下.
能达到最后我所希望的.
我的要求是想每天 2点--5点这个时间段内每隔10分钟 访问指定网页一次.

...全文
279 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Y.A.K.E 2012-11-04
  • 打赏
  • 举报
回复
引用 2 楼 bugs2k 的回复:
Apps use the URL Fetch service to access resources over the web, and to communicate with other hosts using the HTTP and HTTPS protocols. Python applications can use the urllib, urllib2, o……
我用的 就是urllib2 问题是如何定时..GAE有定时任务.
Y.A.K.E 2012-11-04
  • 打赏
  • 举报
回复
引用 1 楼 qq120848369 的回复:
云平台一般不支持socket, 类似的都不支持, 你看看GAE为开发者开放哪些module吧。
GAE支持的,别人还做采集.
bugs2k 2012-11-04
  • 打赏
  • 举报
回复
Apps use the URL Fetch service to access resources over the web, and to communicate with other hosts using the HTTP and HTTPS protocols. Python applications can use the urllib, urllib2, or httplib modules from the Python standard library to access this service, or they can use the App Engine URL Fetch service API. An app can use the Mail service to send email messages on behalf of the application's administrators, or on behalf of the currently signed in user. https://developers.google.com/appengine/docs/python/overview
qq120848369 2012-11-04
  • 打赏
  • 举报
回复
云平台一般不支持socket, 类似的都不支持, 你看看GAE为开发者开放哪些module吧。

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧