使用python和一个Pubmed搜索的斜纹自动化

时间:2014-07-18 22:03:55

标签: python twill pubmed

我正在尝试使用python和twill自动搜索PubMed数据库,但是现在我遇到了一个搜索工作的问题。我的基本代码如下所示:

from twill.commands import *
go("http://www.pubmed.com")
fv("1","term","macropahge")
showforms()

当我运行时,我得到了这个输出:

Form name=EntrezForm (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
1     None                     select    database     [] of [] 
2     None                     select    database     [] of ['gquery'] 
3     None                     select    database     [] of ['assembly'] 
4     None                     select    database     [] of ['bioproject'] 
5     None                     select    database     [] of ['biosample'] 
6     None                     select    database     [] of ['biosystems'] 
7     None                     select    database     [] of ['books'] 
8     None                     select    database     [] of ['clinvar'] 
9     None                     select    database     [] of ['clone'] 
10    None                     select    database     [] of ['cdd'] 
11    None                     select    database     [] of ['gap'] 
12    None                     select    database     [] of ['dbvar'] 
13    None                     select    database     [] of ['epigenomics'] 
14    None                     select    database     [] of ['nucest'] 
15    None                     select    database     [] of ['gene'] 
16    None                     select    database     [] of ['genome'] 
17    None                     select    database     [] of ['gds'] 
18    None                     select    database     [] of ['geoprofiles'] 
19    None                     select    database     [] of ['nucgss'] 
20    None                     select    database     [] of ['homologene'] 
21    None                     select    database     [] of ['medgen'] 
22    None                     select    database     [] of ['mesh'] 
23    None                     select    database     [] of ['ncbisearch'] 
24    None                     select    database     [] of ['nlmcatalog'] 
25    None                     select    database     [] of ['nuccore'] 
26    None                     select    database     [] of ['omim'] 
27    None                     select    database     [] of ['pmc'] 
28    None                     select    database     [] of ['popset'] 
29    None                     select    database     [] of ['probe'] 
30    None                     select    database     [] of ['protein'] 
31    None                     select    database     [] of ['proteinclusters'] 
32    None                     select    database     [] of ['pcassay'] 
33    None                     select    database     [] of ['pccompound'] 
34    None                     select    database     [] of ['pcsubstance'] 
35    None                     select    database     [] of ['pubmed'] 
36    None                     select    database     [] of ['pubmedhealth'] 
37    None                     select    database     [] of ['snp'] 
38    None                     select    database     [] of ['sra'] 
39    None                     select    database     [] of ['structure'] 
40    None                     select    database     [] of ['taxonomy'] 
41    None                     select    database     [] of ['toolkit'] 
42    None                     select    database     [] of ['toolkitall'] 
43    None                     select    database     [] of ['toolkitbook'] 
44    None                     select    database     [] of ['unigene'] 
45    term                     text      term         macropahge 
46 1  None                     submi ... search        
47    EntrezSystem2.PEntre ... hidden    (None)       home 
48    EntrezSystem2.PEntre ... hidden    (None)        
49    EntrezSystem2.PEntre ... hidden    (None)       pubmed 
50    EntrezSystem2.PEntre ... hidden    (None)       pubmed 
51    EntrezSystem2.PEntre ... hidden    (None)        
52    EntrezSystem2.PEntre ... hidden    (None)        
53    EntrezSystem2.PEntre ... hidden    (None)        
54    EntrezSystem2.PEntre ... hidden    (None)        
55    EntrezSystem2.PEntre ... hidden    (None)        
56    EntrezSystem2.PEntre ... hidden    (None)        
57    EntrezSystem2.PEntre ... hidden    (None)        
58    EntrezSystem2.PEntre ... hidden    (None)        
59    EntrezSystem2.PEntre ... hidden    (None)        
60    EntrezSystem2.PEntre ... hidden    (None)        
61    EntrezSystem2.PEntre ... hidden    (None)        
62    p$a                      hidden    p$a           
63    p$l                      hidden    p$l          EntrezSystem2 
64    p$st                     hidden    p$st         pubmed 
65    SessionId                hidden    SessionId    CE8B4A8E3C997DA1_0124SID 
66    Snapshot                 hidden    Snapshot     /projects/entrez/pubmed/PubMedGroup@1.54 

<generator object __call__ at 0x030B8170>

所以我知道我的代码正确地设置了搜索词,但是当我提交时,它不起作用。

submit()
find("macrophage")

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    find("macrophage")
  File "C:\Users\Ed\AppData\Roaming\Python\Python27\site-packages\twill\commands.py", line 239, in find
    raise TwillAssertionError("no match to '%s'" % (what,))
TwillAssertionError: no match to 'macrophage'

所以,我提交错误或使用了错误的提交框。我知道当我搜索时,巨噬细胞这个术语会出现在页面上,所以在提交步骤中出现了问题。任何帮助表示赞赏。当我尝试像“; lkjasdlfkjasd”这样的垃圾短语时,我希望“找不到任何物品”,但我也看不到。

0 个答案:

没有答案