Git Product home page Git Product logo

hacker-news-scraper's Introduction

hacker-news-scraper

This is a scraper for the popular website Hacker News. It scrapes the site outputting post information in the form of JSON.

Getting Started

Here are all the instructions you need to get up and running.

Prerequisites

This project depends upon the following:

Installation

  1. Clone the repository to your local machine
  2. Navigate to the folder

Run the command:

npm install

If this had been pushed up as an npm package, you could simply install it by running "npm install package-name", however since it is not on npm, you can simulate this behaviour by running:

npm link

You will now be able to run the hackernews command from anywhere on your machine. When you are done playing around you can unlink by running:

npm unlink

Running the script

To run the script execute the following command, providing the number of posts (positive integer between 1 and 100) you would like to fetch:

hackernews --posts 100

Output Format

The output format is JSON, which will be outputted to STDOUT.

Here is a sample of the output:

[
  {
    "title": "Amazon increases minimum wage for all U.S. workers to $15 an hour",
    "uri": "https://techcrunch.com/2018/10/02/amazon-minimum-wage/",
    "author": "doppp",
    "points": 527,
    "comments": 416,
    "rank": 1
  },
  {
    "title": "A History of .NET Runtimes",
    "uri": "http://mattwarren.org/2018/10/02/A-History-of-.NET-Runtimes/",
    "author": "edroche",
    "points": 104,
    "comments": 27,
    "rank": 2
  }
]

Running using docker

Run the following command in the root directory:

docker build -t hackernews .

After the image has been built, run the following command, providing an argument for number of posts:

docker run hackernews --posts 100

Dependencies

  • Minimist - This package helps out with parsing command line arguments
  • Axios - HTTP client for making requests
  • Cheerio - Allows us to parse HTML with a jQuery like API
  • Valid-Url - This allows us to check if URL's are valid

hacker-news-scraper's People

Contributors

wolakec avatar

Watchers

James Cloos avatar  avatar

Forkers

drioemgaoin

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.