Skip to content

Instantly share code, notes, and snippets.

@wintrdotcom
Last active September 7, 2020 12:35
Show Gist options
  • Save wintrdotcom/3aa8b5ef866b202dc49bca8657ab9fe9 to your computer and use it in GitHub Desktop.
Save wintrdotcom/3aa8b5ef866b202dc49bca8657ab9fe9 to your computer and use it in GitHub Desktop.
Scrape Ebay product list, get a free WINTR API key on https://www.wintr.com
const WINTR_API_KEY = "your_wintr_api_key"
const TARGET_URL = "https://www.ebay.com/sch/i.html?_nkw=phone"
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": {
"list": {
"group": "#srp-river-results .s-item__wrapper",
"data": {
"name": {
"selector": ".s-item__info .s-item__link",
"attr": "*text*",
"modifier": [
"totrimmed"
]
},
"rating": {
"selector": ".s-item__info .b-starrating .clipped",
"attr": "*text*",
"replacer": [
{
"search": " out of 5 stars.",
"replace": ""
}
],
"modifier": [
"totrimmed"
]
},
"price": {
"selector": ".s-item__details > div:first-child",
"attr": "*text*",
"modifier": [
"totrimmed"
]
},
"thumbnail": {
"selector": ".s-item__image-section img.s-item__image-img",
"attr": "src",
"modifier": [
"totrimmed"
]
},
"link": {
"selector": ".s-item__info .s-item__link",
"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