开发者

Why does Pubmed generate different results from a PHP script than from a manual search?

I've written a PHP script that automatically searches the NCBI Pubmed database based on a user input. It's quite a large script and I won't bother putting it all in here. But one problem that I can't figure out is why, when I search Pubmed using esearch (one of the eutils) I get a different result if it's done using a PHP script than when it's done manually?

Let me give you an example. You can manually enter this into a browser window: http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+Nature[jour]&retmode=xml

You'll see it generates an XML file where the Count field (the number of hits) is 5986.

But if I use the following PHP script:

<?php
$test = simplexml_load_file('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+Nature[jour]&retmode=xml');
echo $test->Count;
?>

It returns a value of 0. This seems to happen whenever a search term is modified to include an additional field, or a non-standard field contains more than one search term. In this case it's the number of searches that "Cancer" brings up but restricted to publications in the journal "Nature", the second field. If I modify the search term so that it looks for cancer and DNA ('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+DNA&retmode=xml'), two different search terms within the same field, it works fine in the script.

If I search within a single non-standard field: ('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=Nature[jour]&retmode=xml') it works fine - but if I then modify it to include two terms in the journal field ('http://eutils.ncbi.nlm.nih.g开发者_开发问答ov/entrez/eutils/esearch.fcgi?db=pubmed&term=Science[jour]+OR+Nature[jour]&retmode=xml') the discrepancy between manual and PHP generated returns.

Does anyone have any idea why this might be happening?

Thanks for any help you could offer.


This works:

<?php

$result = file_get_contents('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+Nature[jour]&retmode=xml');
$xml = simplexml_load_string($result);
echo $xml->Count; // = 5986

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜