我有一个Python代码scrape.py
,我想在App Engine上运行它,它存储在我的存储库中,并且库都在文件夹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起作用,因为在我的应用发动机统计数据中,每10m进行一次活动,但我不知道这是否适用于每10m一次运行代码。
错误
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
您的cron.yaml
目标/
,但是app.yaml
中没有/
的处理程序。
您说统计数据正在显示活动。日志是否显示错误?