2
我正在嘗試使用機械來從各種網站上查詢和收集數據。我已經跨州機械化錯誤 - Python
No handlers could be found for logger "mechanize"
此錯誤不給它發生時的錯誤,這使得調試非常困難的特定位置的錯誤運行。我在網上看過,並且看到機械化版本0.1.11已經解決了這個問題。我已經下載了一個更新的機械化版本,並且想象這應該不再是一個問題。我的代碼導致此問題是
def KEGG(textfile):
KEGGString = ''
KEGGList = []
original = open('Final.txt', 'r')
for row in original:
data = re.split("(#|\t)", row) ##splits text files by tabs into separate strings
new_items = [x if x!='\t' else 'None' for x in data] ##replaces extra tabs with "None"
KEGGList.append(new_items[-1])
KEGGHeaderless = KEGGList[1:] ## Removes header (Cross-Reference (KEGG)) from the list.
KEGGHeaderless = [s.replace(';', '') for s in KEGGHeaderless]
fo = open('KEGG Description.txt', 'w')
for row in KEGGHeaderless:
geneID = row
base2 = 'http://www.genome.jp/dbget-bin/www_bget?'
url = base2 + geneID
br = Browser()
br.set_handle_robots(False)
br.open(url)
for line in KEGGHeaderless:
targetURL = '/dbget-bin/get_linkdb?-t+pathway+' + row
try:
site = br.follow_link(url=targetURL)
br.open(site)
page = br.response().read()
fo.write(page)
except:
fo.write(line + "None\n")
fo.close()
有關如何解決此問題的任何建議?
謝謝!這工作。 – Marea