Last active
September 7, 2020 12:35
-
-
Save wintrdotcom/5d4a63d3d28bdfab53bce25d327050d9 to your computer and use it in GitHub Desktop.
Scrape Ebay product details, get a free WINTR API key on https://www.wintr.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WINTR_API_KEY = "your_wintr_api_key" | |
const TARGET_URL = "https://www.ebay.com/itm/233697752117" | |
const axios = require("axios") | |
const options = { | |
method: "post", | |
responseType: "json", | |
data: { | |
"apikey": WINTR_API_KEY, | |
"url": TARGET_URL, | |
"jsrender": true, // comment this to run the query faster (it might fail more often tho) | |
"renderuntil": "domloaded", // comment this to run the query faster (it might fail more often tho) | |
"headers": { | |
"Accept-Language": "en-US,en;q=0.9,es;q=0.8", | |
"Referer": "https://www.google.com" | |
}, | |
"outputschema": { | |
"details": { | |
"group": "html", | |
"data": { | |
"name": { | |
"selector": "title", | |
"attr": "*text*", | |
"replacer": [ | |
{ | |
"search": "| eBay", | |
"replace": "" | |
} | |
], | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"rating": { | |
"selector": "span[itemprop=\"aggregateRating\"] a.reviews-star-rating", | |
"attr": "title", | |
"replacer": [ | |
{ | |
"search": ", See all product reviews", | |
"replace": "" | |
} | |
], | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"price": { | |
"selector": "span[itemprop=\"price\"]", | |
"attr": "*text*", | |
"replacer": [ | |
{ | |
"search": " ", | |
"replace": " " | |
} | |
], | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"thumbnail": { | |
"selector": "meta[name=\"twitter:image\"]", | |
"attr": "content", | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"description": { | |
"selector": "meta[name=\"description\"]", | |
"attr": "content", | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"link": { | |
"selector": "link[rel=\"canonical\"]", | |
"attr": "href", | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"seller_name": { | |
"selector": ".si-content a[aria-label^=\"Member ID\"]", | |
"attr": "*text*", | |
"modifier": [ | |
"totrimmed" | |
] | |
}, | |
"seller_link": { | |
"selector": ".si-content a[aria-label^=\"Member ID\"]", | |
"attr": "href", | |
"modifier": [ | |
"totrimmed" | |
] | |
} | |
} | |
} | |
} | |
}, | |
url: "https://api.wintr.com/fetch" | |
} | |
axios(options) | |
.then((result) => { | |
console.log(result.data.content) | |
}) | |
.catch((err) => { | |
console.error(err) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment