npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stayko/airbnb-scraper

v1.0.4

Published

AirBnb scraper

Downloads

3

Readme

AirBnb Scraper

Scapes AirBnb listing pages

Requirements

Requires Node V10+ for 'fs' promises

Installation

npm install @stayko/airbnb-scraper

Usage

import Scraper from '@stayko/airbnb-scraper';

const scraper = new Scraper("https://www.airbnb.com/rooms/28299515?location=London%2C%20United%20Kingdom&adults=1&toddlers=0&guests=1&check_in=2019-04-26&check_out=2019-04-30&s=-xq9rVl0")

//Promise
scraper.scrapeHTML().then(result => console.log(result));

//async await
const result = await scraper.scrapeHTML();

/*
Example result:

{ 
  title: 'HS4-5 Premium Location in Heart of Brick Lane!',
  location: 'Greater London',
  description:
   [ 
    'Private room in apartment2 guests1 bedroom1 bed2 shared baths',
    'Sparkling clean · 9 recent guests“Arturs flat is nice, clean and tidy.”',
    'Self check-inCheck yourself in with the keypad.',
    'Great check-in experience95% of recent guests gave the check-in process a 5-star rating.',
    ],
  amenities:
   [
     'Wireless Internet',
     'Kitchen',
     'Dryer',
     'Laptop friendly workspace'
    ],
  images:
   [ 
    'https://a0.muscache.com/im/pictures/dbca3c9b-1ec6-4a6d-bfe6-66acfc51ec5d.jpg?aki_policy=xx_large',
    'https://a0.muscache.com/im/pictures/4921db74-ab6b-4da7-b504-12ea3139b3f2.jpg?aki_policy=large',
    'https://a0.muscache.com/im/pictures/78556ddc-8183-48ea-9e72-8bb9567ef5ca.jpg?aki_policy=large',
    'https://a0.muscache.com/im/pictures/96a10fc5-b280-41f0-b6b1-8f692e72b8a6.jpg?aki_policy=large',
    'https://a0.muscache.com/im/pictures/f2697a94-ded8-42cd-8136-f49e37a9666c.jpg?aki_policy=large' 
    ] 
 }

/*

Selectors

//default selector rules for scraping different elements of the page
{
    title: "#room #summary h1 > span",
    location: "div[data-location] > a > div",
    description: "#summary + div > div > div > div",
    amenities: "#room #amenities td > div",
    images: "#room meta[itemprop=image] + div div > img:nth-child(2)"
}

//they can be overriden via the constructor or setSelectors method
const newSelectorsObj = {title: "new selector rule for title"};

const scraper = new Scraper(url, newSelectorsObj);

scraper.setSelectors(newSelectorsObj);

Utility functions

import Scraper from '@stayko/airbnb-scraper';

const scraper = new Scraper("https://www.airbnb.com/rooms/28299515?location=London%2C%20United%20Kingdom&adults=1&toddlers=0&guests=1&check_in=2019-04-26&check_out=2019-04-30&s=-xq9rVl0")

const result = await scraper.scrapeHTML();

Scraper.saveImagesToDisk(result.images, '/saved/images'); //saves all images to specified directory
Scraper.saveTextToDisk(result.title, '/saved/file.txt'); //saves scraped text to specified text file