How to run Newspaper (the Python 2.7 version) in an Amazon Lambda function:
- Start a new EC2 instance with the Amazon Linux AMI
sudo yum install gcc gcc-c++ libjpeg-devel zlib-devel libevent-devel libxml2-devel libxslt-devel libpng-develsudo yum install python27-devel python27-pipvirtualenv envsource env/bin/activatesudo /usr/bin/easy_install lxmlpip install newspapernano env/local/lib/python2.7/site-packages/newspaper/settings.py- change
DATA_DIRECTORYvariable value to'/tmp/.newspaper_scraper'
- change
zip -9 bundle.zip lambda_function.pycd $VIRTUAL_ENV/lib/python2.7/site-packageszip -r9 ~/bundle.zip *cd $VIRTUAL_ENV/lib64/python2.7/site-packageszip -r9 ~/bundle.zip *- Upload the
bundle.zipfile to your Lambda function- This assumes a default Handler set to
lambda_function.lambda_handler
- This assumes a default Handler set to
- Delete your EC2 instance
I have a few questions. Why a new EC2 instance was created? Can it not be done on Ubuntu machine or Mac?
Do you have any suggestions for newspaper3K version?