Giter VIP home page Giter VIP logo

curry-digger's Introduction

What it this?

I needed to extract information from some pages; I wanted to try out functional programming in javascript; I built this.

You can read more about it here.

Libraries

As described in the article above, this project is mostly about plumbing, i.e. controlling how data is routed between components. These libraries do most of the heavy lifting:

  • request: we'll use to perform a GET request to a URL and get the HTML back
  • Cheerio: let's us use jQuery-like selectors to select and extract text from HTML elements
  • Ramda: the FP utility library
  • Sanctuary: we'll just use it for the Maybe and Either implementations. It would have been possible to use it as an FP utility library as well, instead of Ramda.
  • Fluture: for the implementation of Future

I want to use this. What do I do?

Currently, there's no library on npm, probably never will be.

Interesting stuff is in the scraper.js file. You should probably leave the scrapeUrl function alone, and just build your own decoder functions (those will depend on the web pages you want to scrape. Look at decodeMovie and decodeActorMovieUrls for examples).

Each decoder function is then passed as an argument to scrapeUrl which will return a Future. You can keep adding stuff to your scraping pipeline by mapping and chaining on that Future until you're ready to fork it.

If anything of this is new to you, I really recommend reading the article above, in which I describe in excruciating detail how I got to this solution.

Tests

There are some tests, specifically for the utility functions that define the API for cheerio and request. To run them:

npm test

curry-digger's People

Contributors

rjbma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.