Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

scrapy javascript

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

(async () => {
  const args = process.argv.slice(2);
  const postCode = args[0] || 2000;
  const url = `https://www.domain.com.au/rent/?postcode=${postCode}&excludedeposittaken=1`;
  try {
    const response = await axios.get(url);
    const $ = cheerio.load(response.data);
    const noOfProperties = $('h1>strong').text();
    console.log(`${noOfProperties} are open for rent in ${postCode} postcode of Australia on Domain`);
  } catch (e) {
    console.error(`Error while fetching rental properties for ${postCode} - ${e.message}`);
  }
})();


//website with javascript

const puppeteer = require('puppeteer');

(async () => {
  try {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    const navigationPromise = page.waitForNavigation();

    await page.goto('https://jobs.workable.com/');
    await page.setViewport({ width: 1440, height: 744 });
    await navigationPromise;

    await page.waitForSelector('ul li h3 a');
    let jobTitles = await page.$$eval('ul li h3 a', titles => {
      return titles.map(title => title.innerText);
    });
    console.log(`Job Titles on first page of Workable are: ${jobTitles.join(', ')}`);
    await browser.close();
  } catch (e) {
    console.log(`Error while fetching workable job titles ${e.message}`);
  }
})();
Comment

PREVIOUS NEXT
Code Example
Javascript :: inner html jquery 
Javascript :: joi validation 
Javascript :: unsubscribe all youtube channel using javascript 
Javascript :: create component with module and routing in angular 8 
Javascript :: How to Use the toUpperCase() String Method in javascript 
Javascript :: 0.1+0.2 javascript 
Javascript :: discord.js edit message by id 
Javascript :: hex string to buffer nodejs 
Javascript :: how to make one line if in js 
Javascript :: js foreach 
Javascript :: regular expressions password contains number 
Javascript :: split decimal value in javascript 
Javascript :: bootstrap disable button after click 
Javascript :: js get last array element 
Javascript :: react hook form with yup resolver 
Javascript :: reactjs cdn 
Javascript :: preventdefault not working react 
Javascript :: Get LocalStorage from WebView react native 
Javascript :: moment time format by country 
Javascript :: question mark and colon in javascript 
Javascript :: express req body undefined 
Javascript :: ajax onchange dropdown 
Javascript :: javascript add text to li 
Javascript :: javascript right trim 
Javascript :: react public pic 
Javascript :: smooth scroll mouse wheel javascript 
Javascript :: e.target.text react 
Javascript :: jquery datatable checkbox checked row data 
Javascript :: All Longest Strings javaScript 
Javascript :: javascript round to 8 decimal places 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =