New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stayko/airbnb-scraper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stayko/airbnb-scraper

AirBnb scraper

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-92.86%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 29 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc