Git Product home page Git Product logo

open-graph-scraper's Introduction

open-graph-scraper

An open graph protocol scraper made with ExpressJS on top of NodeJS and Cheerio. Will get ogTags like title, image, description etc.If Open Graph Protocol tags are not available, searches for other metadata. Implements caching internally using node-cache so that the same requests if cached can be served quicker. Also has unit tests on top of this with Mocha and Chai. For more information on Open Graph Protocol, please check out https://ogp.me/.

If you have any doubts or clarifications on this code, hit me up and I'll try to help you guys out!

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You'll need to install NodeJS for running this application. I'm on Node v10.5.3, you can find it at:

https://nodejs.org/en/download/

You'll also need a code editor to see how the code goes. Use whichever editor which has JS support, I use Visual Studio Code on Windows 10.

Installing

Simple steps to get the application running. Open the terminal to the folder containing og-scraper-express and just type:

npm install

This should install all the dependencies within package.json and create your package-lock.json and node modules.

After the previous command completes successfully, open the terminal and type:

npm start

This should get the program up and running on the default port.

To run the tests, all you need to do is, type:

npm run test

Usage

Once program is up and running, you can call the endpoint with server_ip/ogScrap. By default, the port should be 3000. On your local machine, server_ip would be http://localhost:3000 (if you haven't specified any port). This is a post request which expects a JSON post body as such:

{
  "url" : "https://duckduckgo.com/?t=hk"
}

I also hosted the same app on heroku. So you guys can run the api by calling a post request to https://arcane-spire-12570.herokuapp.com/ogScrap with the same body as above and see the magic happen.

Built With

  • NodeJS - The language used
  • Express - Framework used on top of node.
  • Cheerio - Package used for parsing OG tags.
  • Node-Cache - Simple NodeJS caching module.
  • Mocha - Test framework for JS.
  • Chai - Assertion library for JS.

Contributing

Anybody with ideas to genuinely improve the project are welcome. We use git flow, so just pull the repo, cut a branch on develop and put a pull request back to us. We will look through the PR as soon as possible. We suggest you make sure your PR passes all unit tests, and add further unit tests for any new functionalities introduced.

Versioning

Currently, no versions are available. Will update soon

Authors

License

This project is free. Use it in whichever way you please.

Acknowledgments

  • Hat tip to anyone whose code was used

open-graph-scraper's People

Contributors

dopecodez avatar

Watchers

 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.