Page MenuHomePhabricator
Paste P8919

RC fetching script
ActivePublic

Authored by Smalyshev on Aug 15 2019, 7:53 PM.
<?php
$NS = "0|120|146";
$url = "https://www.wikidata.org/w/api.php?format=json&action=query&list=recentchanges&rcdir=newer&rcprop=title|ids|timestamp&rcnamespace=$NS&rclimit=500";
$start = '20190813103000';
// $end does not really work for now
// $end = '20190813122000';
$url_data = $url . "&rcstart=" . $start;
do {
$data = file_get_contents($url_data);
$cont = process_data($data);
$url_data = $url . "&continue=-||&rccontinue=" . $cont;
print "Continuing with $cont\n";
} while($cont);
function process_data($data) {
$jdata = json_decode($data, true);
$rc = $jdata['query']['recentchanges'];
foreach($rc as $rcitem) {
// if($rcitem['type'] != 'log') continue;
print $rcitem['title'] . " " . $rcitem['timestamp'] . "\n";
}
return $jdata['continue']['rccontinue'];
}

Event Timeline

Smalyshev created this paste.Aug 15 2019, 7:53 PM