Skip to content

Instantly share code, notes, and snippets.

View 256cats's full-sized avatar

Andrey E 256cats

  • Berlin, Germany
View GitHub Profile
@256cats
256cats / gimmeproxy.php
Last active February 20, 2020 03:10
gimmeproxy.com example
<?php
function getProxy() {
$data = json_decode(file_get_contents('http://gimmeproxy.com/api/getProxy'), 1);
if(isset($data['error'])) { // there are no proxies left for this user-id and timeout
echo $data['error']."\n";
}
return isset($data['error']) ? false : $data['curl']; //gimmeproxy returns 'curl' field that is CURLOPT_PROXY-ready string, see curl_setopt($curl, CURLOPT_PROXY, $proxy);
}
/**
@256cats
256cats / download.php
Created May 8, 2015 10:17
Instagram (API) popular scraper and downloader with redis and curl, description here: http://256cats.com/how-to-scrape-instagram-and-quickly-download-images/
<?php
$dir = __DIR__.'/photos';
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
function get($url) {
//curl get
echo $url."\n";
$curlOptions = array(
CURLOPT_ENCODING => 'gzip,deflate',
@256cats
256cats / composer.json
Last active February 21, 2024 00:58
Web scraping ReactPHP Curl Proxies, curl multi example, scraping news ycombinator, explanation here: http://256cats.com/fast-scraping-with-reactphp-curl-proxies/
{
"require": {
"khr/react-curl": "~2.0",
"sunra/php-simple-html-dom-parser": "~1.5"
}
}
@256cats
256cats / github-api.php
Last active August 26, 2022 01:34
Github Api example
<?php
require_once 'vendor/autoload.php';
use Milo\Github; //https://github.com/milo/github-api/
header('Content-Type: application/json');
$api = new Github\Api;
$token = new Milo\Github\OAuth\Token('your secret key here');
$api->setToken($token);