【问题标题】:Why does Pubmed generate different results from a PHP script than from a manual search?为什么 Pubmed 从 PHP 脚本生成的结果与从手动搜索生成的结果不同?
【发布时间】:2011-04-02 06:28:33
【问题描述】:

我编写了一个 PHP 脚本,它可以根据用户输入自动搜索 NCBI Pubmed 数据库。这是一个相当大的脚本,我不会费心把它全部放在这里。但我不明白的一个问题是,为什么当我使用 esearch(eutils 之一)搜索 Pubmed 时,如果使用 PHP 脚本完成与手动完成时会得到不同的结果?

让我举个例子。您可以在浏览器窗口中手动输入:http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+Nature[jour]&retmode=xml

您会看到它生成了一个 XML 文件,其中 Count 字段(点击次数)为 5986。

但如果我使用以下 PHP 脚本:

<?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;
?>

它返回值 0。每当修改搜索词以包含附加字段或非标准字段包含多个搜索词时,似乎都会发生这种情况。在这种情况下,它是“癌症”提出的搜索次数,但仅限于“自然”杂志第二个字段中的出版物。如果我修改搜索词以查找癌症和 DNA('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=cancer+AND+DNA&retmode=xml' ),在同一字段中有两个不同的搜索词,它在脚本中可以正常工作。

如果我在单个非标准字段中搜索:('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=Nature[jour]&retmode=xml' )它工作正常 - 但如果我随后修改它以在期刊字段中包含两个术语('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=Science[jour ]+OR+Nature[jour]&retmode=xml') 手动和 PHP 生成的返回之间的差异。

有人知道为什么会发生这种情况吗?

感谢您提供的任何帮助。

【问题讨论】:

    标签: php xml search bioinformatics


    【解决方案1】:

    这行得通:

    <?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
    
    ?>
    

    【讨论】:

    • 谢谢!这确实有效。知道为什么吗? simplexml_load_string 解析字符串内容是否与 simplexml_load_contents 不同?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-04
    • 1970-01-01
    • 2023-01-25
    相关资源
    最近更新 更多