Improve page rendering implemented mentioned in Qiita Using jsdom.
- Faster dump speed than using phantomjs
- Supports POST, GET, and possible other types of protocols
- Customizable connection delay time and rendering waiting time
npm install
npm run test
https://{your_lambda_endpoint}?url={URL_ENCODED}[&delay={SECOND}][&method={METHOD}[&dataType={DATA_TYPE}]][&wait={WAIT_SECOND}]
-
URL_ENCODED: target url using encodeURIComponent(url) or something equivalent
-
SECOND: optional, number of seconds allowed for waiting, default value = '5'
-
METHOD: optional, currently only support
GET
andPOST
, default value =GET
-
DATA_TYPE: optional, either
json
orform
, only available when METHOD=POST
. default value =form
-
WAIT_SECOND: optional, time (second) to wait for rendering html, default value =
1
First pack whole project as zip:
zip -r lambda.zip jsdomrenderer
and create Lambda function:
export AWS_DEFAULT_REGION=us-east-1
aws lambda create-function \
--region us-east-1 \
--function-name jsdomrenderer \
--zip-file fileb://lambda.zip \
--role role-arn \
--handler jsdomrenderer.lambdaHandler \
--runtime nodejs6.10 \
--profile adminuser
For more information, see CreateFunction. AWS Lambda creates the function and returns function configuration information.
or use cloudformation:
Create new s3bucket
aws s3 mb s3://bucket-name --region region
And get code-uri:
aws cloudformation package \
--template-file template.yaml \
--output-template-file serverless-output.yaml \
--s3-bucket s3-bucket-name
Finally deploy using:
aws cloudformation deploy \
--template-file serverless-output.yaml \
--stack-name new-stack-name \
--capabilities CAPABILITY_IAM
See Create Serverless Application for more information.