Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fdciabdul/olx-scraper


https://github.com/fdciabdul/olx-scraper

Last synced: 12 days ago
JSON representation

Awesome Lists containing this project

README

        





# OLX Unofficial Client API
[![License: GPL-3.0 license](https://img.shields.io/github/license/fdciabdul/OLX-SCRAPER?style=plastic)](https://opensource.org/licenses/Artistic-2.0)
[![npm version](https://badge.fury.io/js/olx-scraper.svg)](https://badge.fury.io/js/olx-scraper)[![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)

Unofficial Scraper API for OLX.CO.ID

## Installation

You can install the package using npm or Yarn:

```bash
npm install olx-scraper
```
or

```bash
yarn add olx-scraper
```
## Usage

### Logging in

To log in to OLX:

```javascript
const { OLXClient } = require("olx-scraper");
const client = new OLXClient('[email protected]', 'your-password');

client.loginOLX().then(response => {
console.log(response);
}).catch(error => {
console.error(error);
});
```

### Fetching User Data

Retrieve user data from OLX by user ID:

```javascript
client.getUserData(userId, cookie).then(userData => {
console.log(userData);
}).catch(error => {
console.error(error);
});
```

### Getting Categories

Get a list of categories available on OLX:

```javascript
client.getCategory().then(categories => {
console.log(categories);
}).catch(error => {
console.error(error);
});
```

### Searching by Category

Search for listings in a specific category:

```javascript
client.searchbyCategory(categoryId, locationId).then(searchResults => {
console.log(searchResults);
}).catch(error => {
console.error(error);
});
```

### Searching for Locations

Search for locations on OLX:

```javascript
client.searchLocation('location-query').then(locations => {
console.log(locations);
}).catch(error => {
console.error(error);
});
```