Skip to content

Instantly share code, notes, and snippets.

@turnipsoup
Created May 25, 2018 01:00
Show Gist options
  • Save turnipsoup/f2ded7e60159ba8a823dcca0477dc9b9 to your computer and use it in GitHub Desktop.
Save turnipsoup/f2ded7e60159ba8a823dcca0477dc9b9 to your computer and use it in GitHub Desktop.
Used to pull the cragslist posting on a given URL
var cheerio = require("cheerio");
var request = require('request');
request("https://seattle.craigslist.org/d/science-biotech/search/sci", function (error, response, html) {
if (!error) {
var $ = cheerio.load(html)
$("li.result-row").each(function (i, element) {
var obj = {}
var b = $(this)
obj["title"] = b.children().children().text()
obj.title = obj.title.replace(/\s/g, '').split("favoritethispost")[1].split("(")[0]
obj["href"] = b.children().children("a").attr("href")
console.log(obj)
console.log()
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment