Commit 59454844 authored by jlopez's avatar jlopez
Browse files

Fix CRAN packages

parent 1c9218ba
......@@ -261,19 +261,39 @@ function findRPackage($os_name, $version_num, $version_name, $keyword, $limit, $
$repos = "github";
}
$basic_url = "https://rdrr.io/find/?repos=".$repos."&fuzzy_slug=";
$results = [];
$url_packages = $basic_url.$keyword;
if($repos == "cran") {
$filename = './packages/cran/packages.csv';
if (($h = fopen("{$filename}", "r")) !== FALSE) {
$doc = getDocument($url_packages);
$index = 0;
$trs = $doc->getElementsByTagName('tr');
while (($data = fgetcsv($h, 1000, ";")) !== FALSE) {
$name = $data[0];
$size = $trs->length;
if(strpos($name, $keyword) !== false){
for ($i = 1; $i <= $size; $i++) {
var_dump($trs[$i]->childNodes[1]->childNodes[0]);
$version = $data[1];
$description = $data[2];
$link = "https://cran.r-project.org/package=".$name;
$other = $data[3];
$package = new Package($name, $version, $description, $link, $other);
$results[] = $package;
$index++;
if($index == $limit) {
break;
}
}
}
// Close the file
fclose($h);
}
}
......
This diff is collapsed.
Supports Markdown
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