Skip to content

Commit

Permalink
feat: update script to scrape zillow
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Jan 9, 2023
1 parent 83a23f5 commit c455966
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions node-scrape-zillow/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
/* const unirest = require('unirest');
async function zillow() {
const target_url = "https://www.zillow.com/homes/for_sale/";
const zillow_data = await unirest.get(target_url);
return zillow_data.body;
}
zillow().then((data) => {
console.log(data);
});*/

const unirest = require('unirest');
const cheerio = require('cheerio');

async function zillow() {
const target_url="https://www.zillow.com/homes/for_sale/";
const zillow_data = await unirest.get(target_url);

console.log(zillow_data.body);

const $ = cheerio.load(zillow_data.body);

if (zillow_data.statusCode === 200) {
$('.list-card-info').each(function() {
$('.list-card-info').each(function () {
const price = $(this).find('.list-card-price').text();
const address = $(this).find('.list-card-addr').text();
const bedrooms = $(this).find('.list-card-details li:nth-child(1)').text();
Expand Down

0 comments on commit c455966

Please sign in to comment.