Commit 0eb6868c authored by colemanw's avatar colemanw

Fix scraping drupal.org for project stats

parent 5eab9962
......@@ -51,11 +51,10 @@ class civicrm_org_stats_drupal extends civicrm_org_stats {
if ($html === FALSE) {
return FALSE;
}
$html = strstr($html, '</strong>', TRUE);
$html = strstr($html, 'Reported installs');
$html = strstr($html, '>');
$html = str_replace(array('>', ','), '', $html);
return is_numeric($html) ? $html : FALSE;
$html = stristr($html, 'project information</h3>');
$matches = [];
preg_match('#<strong>([0-9,]+)</strong>#', $html, $matches);
return !empty($matches[1]) ? str_replace(',', '', $matches[1]) : FALSE;
}
......@@ -67,8 +66,7 @@ class civicrm_org_stats_drupal extends civicrm_org_stats {
private function fetch($name) {
$returnedRawValues = drupal_http_request(self::URL . $name);
if (empty($returnedRawValues->error) && !empty($returnedRawValues->data)) {
$html = strstr($returnedRawValues->data, '<h3>Project Information</h3>');
return $html;
return $returnedRawValues->data;
}
return FALSE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment