GithubHelp home page GithubHelp logo

kieranroneill / airbnb-scraper Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 2.06 MB

A simple web scrapper that uses Puppeteer under the hood to scrape an Airbnb listing and shove it into a MongoDB.

License: Other

Dockerfile 6.81% JavaScript 2.47% TypeScript 90.71%

airbnb-scraper's Introduction

Airbnb Scraper

A simple web scrapper that uses Puppeteer under the hood to scrape an Airbnb listing and shove it into a MongoDB.

Table of contents

Introduction

Below is a quick outline of the structure of the app:

.
├── api                        # API routes
|   ├── listing.ts
│   └── ...
├── config                     # Various configuration objects
|   ├── db.ts   
│   └── ...
├── interfaces                 # TS interfaces
|   ├── listing.ts
│   └── ...
├── middlewares                # Custom Express middlewares
|   ├── errorHandler.ts
│   ├── ...
├── models                     # MongoDB models
|   ├── listing.ts
│   └── ...
├── modules                    # Modules are used to separate code to make it more testable
|   ├── puppeteer              # This handles all the Puppeteer magic
|   |   ├── scrapeListing.ts
|   |   ├── index.ts
|   │   └── ...
│   └── ...
├── schemas                    # MongoDB schemas
|   ├── listing.ts
│   └── ...
├── index.ts                   # Entrypoint - starts the server.
└── server.ts                  # This is where the Express app is setup and configured.

Getting started

These are the instructions that tell you how to get up and running.

1. Prerequisites

2. Running the server

  1. Build the image and start the container:
docker-compose up
  1. Once the container is up it will be running on: http://localhost:1337

Development

1. Setting up the dev environment

2. Running locally

  1. Install the node_modules:
yarn install
  1. Copy the .env.example into a .env file using:
cp -n .env.example .env
  1. Ensure MongoDB is running.

  2. Start the server:

yarn start
  1. You can check the API using the following cURL command:
curl -X POST \
  http://localhost:1337/api/listing \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://www.airbnb.co.uk/rooms/28299515?location=London%2C%20United%20Kingdom&toddlers=0&_set_bev_on_new_domain=1572300146_ZKC6996OiM8G0CT3&source_impression_id=p3_1572300147_bRb1KSr%2FXjuPRPDg&guests=1&adults=1"}'
  1. (Optional) If you installed a MongoDB GUI client, you can now see the listing has been created/updated.

3. Testing

  • You can run the tests using:
yarn test
  • You shouldn't need your mongod running (or even installed) as the tests spin up an in-memory MongoDB and tear down at the end.

Credits

airbnb-scraper's People

Stargazers

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