php抓取NCIB中pubmed文献数据(6)
发布时间:2021-06-06
发布时间:2021-06-06
print "$count items found\n";
$translated = (string) $xml->QueryTranslation;
printf("Translated query: %s\n\n", $translated);
$params = array(
'db' => 'pubmed',
'retmode' => 'xml',
'query_key' => (string) $xml->QueryKey,
'WebEnv' => (string) $xml->WebEnv,
'retmax' => $count,
);
$url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' . http_build_query($params); print "URL: $url\n";
$file = sprintf('%s.xml', preg_replace('/\W/', '_', $translated));
$file = $pubmedyear."-".$pubmedmonth."-".$pubmedday."_$file";
$wgetfilelog="wget.{$file}.log";
system(sprintf("wget %s -O %s 1>& $wgetfilelog", escapeshellarg($url),
escapeshellarg($file)),$ret);
$flag=wget_errors($wgetfilelog);
$flag_xml=xml_is_read($file);
if($ret==0 && $flag==1 && $flag_xml==1){
return $count;
}
else{
return 0;
}
}