Skip to content

Instantly share code, notes, and snippets.

View thbland's full-sized avatar

Troy Bland thbland

View GitHub Profile
@thbland
thbland / node_cheerio_scraping.js
Created August 20, 2021 01:36 — forked from bradtraversy/node_cheerio_scraping.js
Simple example to scrape some posts and put into a CSV file using Node & Cheerio
const request = require('request');
const cheerio = require('cheerio');
const fs = require('fs');
const writeStream = fs.createWriteStream('post.csv');
// Write Headers
writeStream.write(`Title,Link,Date \n`);
request('http://codedemos.com/sampleblog', (error, response, html) => {
if (!error && response.statusCode == 200) {
@thbland
thbland / web-servers.md
Created May 3, 2021 18:09 — forked from cferdinandi/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@thbland
thbland / decoratedFetch.ts
Created April 24, 2021 19:27 — forked from panzerdp/decoratedFetch.ts
An extensible fetch() implementation that uses the decorator pattern
type ResponseWithData = Response & { data?: any };
interface Fetcher {
run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData>;
}
class BasicFetcher implements Fetcher {
async run(input: RequestInfo, init?: RequestInit): Promise<ResponseWithData> {
return await fetch(input, init);
}