我有一个python代码scrape.py
,我想在app引擎上运行它,它存储在我的存储库中,所有库都在lib
文件夹中。
任何人都可以请更正我的app.yaml和cron.yaml。
我的进口
import requests
import re
import mysql.connector
from urlparse import urlparse
from urlparse import urljoin
from bs4 import BeautifulSoup
的app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
script: Scrape.app
handlers:
- url: /lib/requests
script: Scrape.app
handlers:
- url: /requests
script: Scrape.app
handlers:
- url: /mysql/connector
script: Scrape.app
handlers:
- url: /bs4/
script: Scrape.app
处理程序: - url:/ lib / mysql / connector 脚本:Scrape.app
handlers:
- url: /lib/bs4/
script: Scrape.app
cron.yaml
cron:
- description: "Scrape"
url: /
schedule: every 10 mins
retry_parameters:
min_backoff_seconds: 2.5
max_doublings: 10
我注意到我的cron.yaml有效,因为在我的app引擎统计数据中,每隔10米就有一次活动,但我不知道这是否每10米运行一次代码是正确的。
错误
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
/bin/sh: 1: Python: not found
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~tribal-bonito-157700/20170302t182530.399552845921654287/Scrape.py", line 3, in <module>
import requests
ImportError: No module named requests
答案 0 :(得分:0)
您的cron.yaml
目标/
,但/
中没有app.yaml
的处理程序。
你说统计数据显示活动。日志是否显示错误?