Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python和Pubmed搜索的twill实现自动化_Python_Twill_Pubmed - Fatal编程技术网

使用python和Pubmed搜索的twill实现自动化

使用python和Pubmed搜索的twill实现自动化,python,twill,pubmed,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___ __

我正在尝试使用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>
formname=EntrezForm(#1)
#####(名称)(名称)(名称)(名称)(名称)(名称)(名称)(名称)(名称)(名称)(名称)名称(名称)(名称)名称__________________
1无选择数据库[],共[]
2无选择数据库[]的['gquery']
3无选择['assembly'的数据库[]
4无选择['bioproject'的数据库[]
5无选择数据库[]的['biosample']
6无选择数据库[]的['biosystems']
7无选择数据库[]共['books']
8无选择数据库[]的['clinvar']
9无选择['clone'的数据库[]
10无选择数据库[]的['cdd']
11无选择数据库[]的['gap']
12无选择数据库[]的['dbvar']
13无选择数据库[]的['epigenomics']
14无选择数据库[]的['nucest']
15无选择数据库[]的['gene']
16无选择数据库[]的['genome']
17无选择数据库[]的['gds']
18无选择数据库[]的['geoprofiles']
19无选择数据库[]的['nucgss']
20无选择数据库[]的['homologene']
21无选择数据库[]的['medgen']
22无选择数据库[]的['mesh']
23无选择数据库[]的['ncbisearch']
24无选择数据库[]的['nlmcatalog']
25无选择数据库[]的['nuccore']
26无选择数据库[]的['omim']
27无选择数据库[]的['pmc']
28无选择数据库[]的['popset']
29无选择数据库[]的['probe']
30无选择数据库[]的['protein']
31无选择数据库[]共['proteinclusters']
32无选择数据库[]的['pcassay']
33无选择数据库[]的['pccompound']
34无选择数据库[]的['pcsubstance']
35无选择数据库[]的['pubmed']
36无选择数据库[]的['pubmedhealth']
37无选择数据库[]的['snp']
38无选择数据库[]的['sra']
39无选择数据库[]的['structure']
40无选择数据库[]的['taxonomy']
41无选择['toolkit'的数据库[]
42无选择数据库[]的['toolkitall']
43无选择['toolkitbook']的数据库[]
44无选择数据库[]的['unigene']
45学期课文学期大班
46.1无提交。。。搜寻
47 EntrezSystem2.PEntre。。。隐藏(无)家
48 EntrezSystem2.PEntre。。。隐藏(无)
49 EntrezSystem2.PEntre。。。隐藏(无)pubmed
50 EntrezSystem2.PEntre。。。隐藏(无)pubmed
51 EntrezSystem2.PEntre。。。隐藏(无)
52 EntrezSystem2.PEntre。。。隐藏(无)
53 EntrezSystem2.PEntre。。。隐藏(无)
54 EntrezSystem2.PEntre。。。隐藏(无)
55 EntrezSystem2.PEntre。。。隐藏(无)
56 EntrezSystem2.PEntre。。。隐藏(无)
57 EntrezSystem2.PEntre。。。隐藏(无)
58 EntrezSystem2.PEntre。。。隐藏(无)
59 EntrezSystem2.PEntre。。。隐藏(无)
60 EntrezSystem2.PEntre。。。隐藏(无)
61 EntrezSystem2.PEntre。。。隐藏(无)
62便士a隐藏便士a
63 p$l隐藏p$l入口系统2
64 p$st隐藏p$st公共医疗
65会话ID隐藏会话ID CE8B4A8E3C997DA1_0124SID
66快照隐藏快照/projects/entrez/pubmed/PubMedGroup@1.54 
因此,我知道我的代码正确地输入了搜索词,但当我提交时,它不起作用

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'
submit()
发现(“巨噬细胞”)
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
发现(“巨噬细胞”)
文件“C:\Users\Ed\AppData\Roaming\Python27\site packages\twill\commands.py”,第239行,在find中
引发Twillasertionerror(“与“%s”不匹配%(什么,))
TwillAssertionError:与“巨噬细胞”不匹配

因此,我提交错误或使用了错误的提交框。我知道当我搜索时,巨噬细胞这个词会出现在页面上,所以在提交步骤中出现了一些错误。感谢您的帮助。当我尝试像“lkjasdlfkjasd”这样的垃圾短语时,我希望“找不到任何项目”,但我也看不到这一点。

Twill不懂javascript,PubMed页面似乎在使用一些AJAX。您是否尝试获取
http://www.ncbi.nlm.nih.gov/pubmed/?term=macrophage
直接?您是否考虑过使用biopython访问他们的API<代码>Entrez.read(Entrez.esearch(db=“pubmed”,term=“macrophag