我正在使用python设置网络抓取工具,并希望它在Amazon Lambda中运行
使用pycharm时,我导入了“ newspaper3k”包,该包允许从新闻文章的网址中提取文本。 给定的代码运行正常。文件名是“ test.py”
在AWS Lambda中运行时,出现以下错误: “ { “ errorMessage”:“无法导入模块'test'” }“
处理程序是“ test.lambda_handler”
删除“进口报纸”时没有错误。我已经检查了部署程序包,并且有报纸,所以该命令应该可以正常运行。
如何更正?
import requests
from bs4 import BeautifulSoup as BS
import newspaper #error is here
def lambda_handler(event, context):
# TODO implement
url = "https://www.thehindubusinessline.com/todays-paper/tp-opinion/Towards-equity-in-direct-taxes/article20050257.ece"
art = newspaper.Article(url)
art.download()
art.parse()
print(art.text)