Created
April 15, 2016 18:34
-
-
Save Vazkii/e54980cee15c0a374148fb8897b31b8c to your computer and use it in GitHub Desktop.
Patreon Scraper
This file contains 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
156304,Mithion | |
180527,WayofTime | |
230285,mineshopper | |
260704,aidancbrady | |
2812812,swordkorn | |
285334,FiskFille | |
347373,XolovA | |
81876,Mortvana | |
82605,AtomicStryker | |
AbrarSyed | |
Adubbz | |
AfterLifeLochie | |
AlexDGr8r | |
algorithmx2 | |
amadornes | |
amnet | |
Aroma1997 | |
ashjack | |
asie | |
azanor | |
bdew | |
benimatic | |
binnie | |
blay09 | |
BluSunrize | |
BobTheGodly | |
boni | |
calclavia | |
castielq | |
Cojomax99 | |
covers1624 | |
CovertJaguar | |
CrushedPixel | |
cuchaz | |
CyanideX | |
darkevilmac | |
dmillerw | |
DocRedstone | |
doughnutdev | |
drullkus | |
DrZhark | |
dyonovan | |
erasmuscrowley | |
eyamaz | |
f3rullo14 | |
FatherToast | |
FireBall1725 | |
firemerald | |
Funwayguy | |
fyberoptic | |
ganymedes01 | |
GenDeathrow | |
gregoriust | |
hea3ven | |
HQM | |
ichun | |
insaneau | |
ivorius | |
jakimfett | |
jamioflan | |
jaredlll08 | |
Jezza | |
joshiejack | |
Jotato | |
JurassiCraft | |
K4Unl | |
Kihira | |
Lomeli12 | |
lycaon | |
MamiyaOtaru | |
Mark719 | |
maxanier | |
McJty | |
mezz | |
micdoodle8 | |
minemaarten | |
mraof | |
MrTJP | |
NeO_Archangel | |
Noppes | |
npe | |
openmods | |
Ordinastie | |
Pahimar | |
pamsmods | |
Parker8283 | |
Pigs_FTW | |
Pokefenn | |
portablejim | |
profmobius | |
progwml6 | |
Questology | |
quetzi | |
reikasminecraft | |
roboyobo | |
RS485 | |
rwtema | |
sangar | |
SatanicSanta | |
shadowclaimer | |
simcraft4minecraft | |
sinkillerj | |
skyboy | |
Soaryn | |
spitefulfox | |
squeek502 | |
Tahg | |
TeamCoFH | |
TeamMonumental | |
TheRoBrit | |
tmtravlr | |
TTFTCUTS | |
unwrittenfun | |
Vanhal | |
Vazkii | |
Wehavecookies56 | |
wiiv | |
williewillus | |
wuppy29 | |
yorkeMC |
This file contains 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
<?php | |
echo "Patreon scraper mabob"; | |
$accs = file('_accs', FILE_IGNORE_NEW_LINES); | |
$output = "sep=,\nAuthor,Patrons,Pledge Total,Average\n"; | |
foreach($accs as $acc) { | |
$acc_name = $acc; | |
$acc_url = $acc_name; | |
if(strpos($acc_name, ',') > 0) { | |
$tokens = explode(",", $acc_name); | |
$acc_name = $tokens[1]; | |
$acc_id = $tokens[0]; | |
$acc_url = "user?u=$acc_id"; | |
} | |
echo "\n\nScraping $acc_name\n"; | |
$contents = file_get_contents("https://www.patreon.com/$acc_url"); | |
$contents = trim(preg_replace('/\s+/', ' ', $contents)); | |
$contents = preg_replace('/.*?(\{ \"data\"\: \{.*?\});.*/', '$1', $contents); | |
$acc_data = json_decode($contents, true); | |
$attrs = $acc_data['data']['attributes']; | |
$count = $attrs['patron_count']; | |
$pledges = $attrs['pledge_sum']; | |
$dollas = round($pledges / 100.0, 2); | |
if($dollas == 0) { | |
echo "$acc_name is receiving 0\$. Skipping."; | |
continue; | |
} | |
$avg_patron = round($dollas / $count, 2); | |
$str = "$acc_name,$count,$dollas,$avg_patron\n"; | |
$output = "$output$str"; | |
echo "$acc_name has $count patrons for a total of \$$dollas, average \$$avg_patron."; | |
} | |
file_put_contents('output.csv', $output); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment