Coder Social home page Coder Social logo

skew202 / openfaas_scraper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bkrmdahal/openfaas_scraper

0.0 1.0 0.0 627 KB

Example of function for openfaas. This function scrape the website and return the text and word counts.

License: MIT License

Python 100.00%

openfaas_scraper's Introduction

openfaas_scraper

Example of function for openfaas. This function scrape the website and return the text and word counts.

openfaas

Download openfaas and make new function templates

echo "set variables "
IP = "1XX.XX.XXX.XX"

echo "Get openfaas from github"
git clone https://github.com/openfaas/faas

echo "start the swarm"
docker swarm init --advertise-addr $IP

echo "deploy openfass"
cd faas
./deploy_stack.sh --no-auth

echo "get openfaas cli"
curl -sSL https://cli.openfaas.com | sudo sh

echo "Make new folder"
mkdir -p ~/functions && \
  cd ~/functions
  
echo "make new funcation templates"
faas-cli new --lang python scraper


echo "if auth id one login"
# faas-cli login -u admin -p xxxxxxxxxxxx

Update the handler.py with your desired code and than deploy function

faas-cli build -f ./scraper.yml && \
  faas-cli deploy -f ./scraper.yml

Endpoints

Endpoint: /function/scraper

TYPE: GET

INPUT: TEXT

'{
 "url": "https://blog.alexellis.io/rss/",
 "threshold": 2
}'

OUTPUT

{
  "status": "ok",
  "url": "http://www.rpy3.com",
  "word_count": 57,
  "text_counts": {
    "api": 2
  },
  "text": "rpy3\ntoggle navigation\nrpy3\nhome\nabout\nrpy3\nfun begins\neach project 
  has api and web interface.\ntext api\nfind part-of-speech tagging, 
  noun phrase extraction, sentiment analysis, classification, translation, 
  and more of any sentence. you can also use api at /v1/api/text with 
  payload \"data\".\nslove sudoku\nsolve any normal sudoku. replace empty space by 
  .(dot) and move from left to right. enter all 81 digits and your good to go. 
  e.g for above image its 2.............62....1....7...6..8...3...9...7...6..4..
  .4....8....52.............3\npdf miner\nextract the text from pdf doc with 
  metadata like location, fonts and textbox size.\nprivacy policy | c
  ontact\ncopyright © 2017",
  "time": 0.5065762996673584
}

EXAMPLE

curl localhost:8080/function/scraper -d '{
 "url": "https://blog.alexellis.io/rss/",
 "threshold": 2
}'

Grafana Dashboard

Install

docker run -d --name=grafana -p 3000:3000 grafana/grafana 

Import dashboard ID 3434

grafana

openfaas_scraper's People

Contributors

bkrmdahal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.