This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require("puppeteer"); | |
const cheerio = require("cheerio"); | |
const sample = { | |
guests: 1, | |
bedrooms: 1, | |
beds: 1, | |
baths: 1, | |
pesosPerNight: 350 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//custom-search-apikey.js | |
/* | |
//Replace with your own api key and credentials | |
const googleCustomSearchApiKey = "BJzaSyCkY6EYcaQlbq57TqXosLEHdG3olY81WLA"; | |
const cx = "0115429292988874712327:lo4lvgeu1bq"; | |
module.exports = { googleCustomSearchApiKey, cx }; | |
*/ | |
const customSearchCredentials = require("./config/custom-search-apikey"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Test file | |
const TodoController = require("../../controllers/todo.controller"); | |
const TodoModel = require("../../model/todo.model"); | |
const httpMocks = require("node-mocks-http"); | |
const newTodo = require("../mock-data/new-todo.json"); | |
// jest.mock("../../model/todo.model"); cant use this with the prototype.save | |
const saveMock = jest.fn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require("cheerio"); | |
const mongoose = require("mongoose"); | |
const puppeteer = require("puppeteer"); | |
const prompt = require("prompt-sync")({ sigint: true }); | |
const fs = require("fs"); | |
const originUrl = "https://www.airbnb.com/s/Ohio/homes"; | |
async function goToAirbnb(page) { | |
await page.goto(originUrl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table> | |
<tr> | |
<th>Company</th> | |
<th>Contact</th> | |
<th>Country</th> | |
</tr> | |
<tr> | |
<td>Alfred Futterkiste</td> | |
<td>Maria Anders</td> | |
<td>Germany</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
Company: "Alfred Futterkiste", | |
Contact: "Maria Anders", | |
Country: "Germany" | |
}, | |
{ | |
Company: "Berglunds snabbköp", | |
Contact: "Christina Berglund", | |
Country: "Sweden" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request-promise"); | |
const cheerio = require("cheerio"); | |
async function main() { | |
const result = await request.get("http://codingwithstefan.com/table-example"); | |
const $ = cheerio.load(result); | |
$("body > table > tbody > tr > td").each((index, element) => { | |
console.log($(element).text()); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request-promise"); | |
const cheerio = require("cheerio"); | |
async function main() { | |
const result = await request.get("http://codingwithstefan.com/table-example"); | |
const $ = cheerio.load(result); | |
$("body > table > tbody > tr").each((index, element) => { | |
console.log($(element).find("td")[0]); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request-promise"); | |
const cheerio = require("cheerio"); | |
async function main() { | |
const result = await request.get("http://codingwithstefan.com/table-example"); | |
const $ = cheerio.load(result); | |
const scrapedData = []; | |
const tableHeaders = []; | |
$("body > table > tbody > tr").each((index, element) => { | |
if (index === 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let request = require("request-promise"); | |
const cookieJar = request.jar(); | |
const fs = require("fs"); | |
request = request.defaults({ | |
jar: cookieJar, | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"User-Agent": | |
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36", | |
}, |
OlderNewer