This file contains hidden or 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"); | |
async function scrapeListings(page, url) { | |
await page.goto(url); | |
const currentUrl = await page.url(); | |
if (currentUrl !== url) { | |
console.log(currentUrl); | |
console.log(url); | |
console.log("We've reached the end!"); |
This file contains hidden or 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
// the main app file | |
import express from "express"; | |
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db) | |
import authenticate from "./authentication"; // middleware for doing authentication | |
import permit from "./permission"; // middleware for checking if user's role is permitted to make request | |
const app = express(), | |
api = express.Router(); | |
// first middleware will setup db connection |
This file contains hidden or 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", | |
}, |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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(); |
NewerOlder