Skip to content

Instantly share code, notes, and snippets.

View cemjotform's full-sized avatar

Cem Göktuğ Sorgun cemjotform

View GitHub Profile
const puppeteer = require('puppeteer');
const getColors = require('get-image-colors');
(async() => {
try {
// Initialize browser and page
const browser = await puppeteer.launch({args: ['--no-sandbox']});
const page = await browser.newPage();
// Open required page and set viewport to process desktop view of website
@cemjotform
cemjotform / fetch.php
Last active June 4, 2018 09:43
Medium PHP#1
// Define regexes for css include types
$styleTagRegex = '/<style[type="text\/css"]?.*?>(.*?)<\/style>/is';
$linkStyleRegex = '/<link(?=[^<>]*?)(?=[^<>]*?(?:href=["\'](.*?)["\']|>))(?=[^<>]*rel=["\']stylesheet["\'])(?:.*?<\/\1>|[^<>]*>)/i';
// Initialize array of css contents
$cssSource = array('internal' => '');
// Get page content