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

olxba-scraper

v1.0.0

Published

A web scraper for the Bosnian listings site olx.ba

Downloads

4

Readme

olxba-scraper

olxba-scraper is a JavaScript library that provides scraping functionality for the olx.ba website. It leverages Puppeteer, a Node.js library for automating browser actions, to scrape and extract data from the website.

Installation

To use olxba-scraper in your project, you can install it via npm:

npm install olxba-scraper

Usage

Here is an example of how to use olxba-scraper:

import Olx from "olxba-scraper";

// Create an instance of olxba scraper
const scraper = new Olx();

// Initialize the scraper
await scraper.init();

// Get listings by search keywords
const listings = await scraper.getListingsBySearch('laptop');

// Print all the listings
listings.getAllListings().forEach((listing) => {
  console.log(listing.title);
  console.log(listing.description);
  console.log(listing.price);
  console.log(listing.location);
});

// Get a specific listing by URL
const listingUrl = 'https://olx.ba/artikal/12345';
const listing = await scraper.getListingByUrl(listingUrl);

// Print the listing details
console.log(listing.title);
console.log(listing.description);
console.log(listing.price);
console.log(listing.location);

// Close the scraper  
await scraper.close();

API

init()

Initialize the scraper. This method must be called before using any of the Olx methods. It launches a Puppeteer browser instance and sets up the page.

close()

Important! Please Call close() when Finished.

Close the scraper. This method closes the Puppeteer browser instance.

getListingByUrl(url)

Retrieve a listing by its URL. This method navigates to the provided URL and extracts the listing details such as title, description, price, and location.

  • url (String): The URL of the listing.

Returns an instance of the Listing class.

getListingsBySearch(keywords)

Retrieve listings from the first page that match the provided search keywords. This method performs a search on the olxba website using the keywords and extracts the listings' details.

  • keywords (String): The search keywords to find listings.

Returns an instance of the Listings class.

getCategories()

Retrieve all categories from the olx.ba website.

Returns an instance of the Categories class.


Categories class

Represents a collection of categories on the olx.ba website.

getAllCategories()

Get all categories.

Returns an array of category objects with the properties name and url.

getCategory(name)

Get a specific category by its name.

  • name (String): The name of the category.

Returns an instance of the Category class.


Category class

Represents a category on the olx.ba website.

getListings()

Retrieve all listings from the first page of the category.

Returns an instance of the Listings class.


Listings class

Represents a collection of listings.

getAllListings()

Get all listings.

Returns an array of listing objects with the properties title, description, price, location, coverImage, and url.

getListing(url)

Get a specific listing by its URL.

  • url (String): The URL of the listing.

Listing class

Represents a listing on the olx.ba website.

getImages()

Retrieve all images associated with the listing.

Returns an array of image URLs.