Add sample scraping/automation example via Phantomjs

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2017-07-03 16:12:51 +00:00
parent 12c12b1a47
commit 32ac150832
4 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,21 @@
### Phantomjs function
[Phantomjs](http://phantomjs.org) is a headless web-browser used for scraping and automation testing. This function will scrape a web-page with the JavaScript sent in through the function.
Example usage:
```
$ time curl --data-binary @cnn.js http://localhost:8080/function/phantomjs
Status: success
CNN - Breaking News, Latest News and Videos
real 0m8.729s
```
This script visits the front page of CNN and once it is fully loaded - scrapes the title.
See [cnn.js](https://github.com/alexellis/faas/tree/master/sample-functions/Phantomjs/cnn.js) as an example of a Phantomjs script.
Another example script [feedly_subscribers.js](https://github.com/alexellis/faas/tree/master/sample-functions/Phantomjs/feedly_subscribers.js) gives the count of subscribers for an RSS Feed registered on Feedly.