Skip to content

Instantly share code, notes, and snippets.

@wintrdotcom
Last active March 11, 2021 12:13
Show Gist options
  • Save wintrdotcom/b49b914c7e70be7fb3a78e8d3856eb02 to your computer and use it in GitHub Desktop.
Save wintrdotcom/b49b914c7e70be7fb3a78e8d3856eb02 to your computer and use it in GitHub Desktop.
Scrape Craiglist listing details, get a free WINTR API key on https://www.wintr.com
const WINTR_API_KEY = "your_wintr_api_key"
const TARGET_URL = "https://losangeles.craigslist.org/wst/clt/d/redondo-beach-western-electric-as-1317/7185139486.html"
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)
"proxytype": "residential",
"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*",
"modifier": [
"totrimmed"
]
},
"price": {
"selector": ".price",
"attr": "*text*",
"modifier": [
"totrimmed"
]
},
"thumbnail": {
"selector": "meta[property=\"og:image\"]",
"attr": "content",
"modifier": [
"totrimmed"
]
},
"description": {
"selector": "meta[property=\"og:description\"]",
"attr": "content",
"modifier": [
"totrimmed"
]
},
"location": {
"selector": "meta[name=\"geo.placename\"]",
"attr": "content",
"modifier": [
"totrimmed"
]
},
"link": {
"selector": "link[rel=\"canonical\"]",
"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