Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyle-n/unofficial-amazon-search
A simple client for searching Amazon
https://github.com/kyle-n/unofficial-amazon-search
amazon amazon-search javascript nodejs scraper scraping typescript web
Last synced: 2 months ago
JSON representation
A simple client for searching Amazon
- Host: GitHub
- URL: https://github.com/kyle-n/unofficial-amazon-search
- Owner: kyle-n
- License: mit
- Created: 2020-05-08T01:24:09.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T17:45:00.000Z (almost 2 years ago)
- Last Synced: 2024-10-19T21:35:14.027Z (3 months ago)
- Topics: amazon, amazon-search, javascript, nodejs, scraper, scraping, typescript, web
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/unofficial-amazon-search
- Size: 1.04 MB
- Stars: 8
- Watchers: 3
- Forks: 6
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unofficial-amazon-search
A simple client for searching Amazon## Install
`npm install unofficial-amazon-search`
or
`yarn add unofficial-amazon-search`
## How to use
`searchAmazon` returns `Promise`.
```typescript
import {searchAmazon, AmazonSearchResult} from 'unofficial-amazon-search';
// OR
const {searchAmazon, AmazonSearchResult} = require('unofficial-amazon-search');searchAmazon('anything you would put in the search bar').then(data => {
console.log(data);
console.log(data.pageNumber) // 1
console.log(data.searchResults[0].title, data.searchResults[0].imageUrl);
});// load other pages by specifying a page number
// or calling getNextPage()
searchAmazon('mad max', {page: 2, includeSponsoredResults: true}).then(data => {
console.log(data.pageNumber) // 2
console.log(data.searchResults) // (page 2 results)
return data.getNextPage();
}).then(data => {
console.log(data.searchResults) // (page 3 results)
});
```The above works in Node and frontend environments with compiled code.
`unofficial-amazon-search` can also be imported from a `` tag and used in raw JS. Importing it will attach the
module to the `window` object. Browser queries are proxied through AllOrigins.win, a limit-free proxy, to avoid CORS issues.```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>My beautiful webpage</title>
<meta charset="UTF-8">
</head>
<body></body>
<script src="path/to/unofficial-amazon-search/_bundles/unofficial-amazon-search.min.js" rel="script">var searchAmazon = window.UnofficialAmazonSearch.searchAmazon;
searchAmazon('123').then(function (data) {
console.log(data.searchResults);
});