Skip to content

Instantly share code, notes, and snippets.

View xprudhomme's full-sized avatar

Xavier Prud'homme xprudhomme

View GitHub Profile
var _global = typeof window === 'object' && window.window === window
? window : typeof self === 'object' && self.self === self
? self : typeof global === 'object' && global.global === global
? global
: this
function bom (blob, opts) {
if (typeof opts === 'undefined') opts = { autoBom: false }
else if (typeof opts !== 'object') {
console.warn('Deprecated: Expected third argument to be a object')
function getResults(pageNum=0) {
return fetch("https://api.dealroom.co/api/v2/companies?cashbust=1624537538583&token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhcHAuZGVhbHJvb20uY28iLCJpc3MiOiJkZWFscm9vbS5jbyIsImlhdCI6MTYyNDQ1ODUwMCwiZXhwIjoxNjI3MDUwNTAwLCJuYmYiOjE2MjQ0NTg1MDAsInVzZXJJZCI6MzAyNDI3MX0.-pMZ6X0sHhb9hA6JQdAnYHgy29d9YEHG3S-OyuZfSIc", {
"headers": {
"accept": "*/*",
"accept-language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
"content-type": "application/json",
"sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"91\", \"Chromium\";v=\"91\"",
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
@xprudhomme
xprudhomme / auth-process.js
Last active March 27, 2020 22:54
auth-process.js
const {BrowserWindow, protocol} = require('electron');
const authService = require('../services/auth-service');
const createAppWindow = require('../main/app-process');
let win = null;
function createAuthWindow() {
destroyAuthWin();
// Create the browser window.
function addLinksToImages(links=[]) {
let images = Array.from(
document.querySelectorAll("div[class='owl-item active'] div[id*=ishitopbanners_] img")
);
images.forEach(
(img,index) => {
const link = links[index] || "https://www.need-sun.fr/fr/4-robes";
img.outerHTML = `<a href="${link}">${img.outerHTML}</a>`;
}
);
function isSmaller(limit) {
 return number => number < limit;
}
function filterArray(listOfNumbers, limit) {
return listOfNumbers.filter(isSmaller(limit));
}
let numbers = [10, 9, 8, 2, 7, 5, 1, 3, 0];
const puppeteer = require('puppeteer');
const browser = puppeteer.launch();
const scrapeMedium = async () => {
await browser;
const page = await browser.newPage();
await page.goto('https://medium.com/search?q=headless%20browser');
const scrapedData = await page.evaluate(() =>
Array.from(document.querySelectorAll('div.postArticle-content a:first-child[data-action-value]'))
$ mkdir thal
$ cd thal
$ npm init
$ npm i --save puppeteer