我正试图为IUPACcondensed on 本网页编写一个报废的程序。
这里G03307GF是ID。我需要这个:
HexNAc(b1-?)[Fuc(a1-?)]GlcNAc(b1-2)Man(a1-3)[HexNAc(b1-?)[Fuc(a1-?)]GlcNAc(b1-2)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)[Fuc(a1-6)]GlcNAc为此,我尝试使用selenium。
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome('', options = chrome_options)
# takes accession number and returns IUPAC
def getIUPAC(acc_no):
url = 'https://glytoucan.org/Structures/Glycans/' + acc_no
driver.get(url)
IUPAC = driver.find_element_by_xpath('//*[@id="descriptors"]/togostanza-iupaccondensed//main/div/pre/code/text()')
driver.close()
return IUPAC
IUPAC = getIUPAC('G37498VS')
print(IUPAC)它说元素不存在。
发布于 2019-05-25 03:55:36
import re
import requests
def getIUPAC(acc_no):
ret = requests.get('https://glytoucan.org/Structures/Glycans/{}'.format(acc_no))
z = re.search('<meta name="description".*?The IUPAC representation is (.+)\.\s+The', ret.content, re.DOTALL | re.MULTILINE)
return z if z else 'Unknown'
print('IUPAC is {}'.format(getIUPAC('G03307GF')))结果是..。
IUPAC is HexNAc(b1-?)[Fuc(a1-?)]GlcNAc(b1-2)Man(a1-3)[HexNAc(b1-?)[Fuc(a1-?)]GlcNAc(b1-2)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)[Fuc(a1-6)]GlcNAc发布于 2019-05-25 19:45:12
最好使用VeNoMouS所示的请求。只是想补充一下,您得到的是element does not exist,因为在您打印它之前,驱动程序已经关闭。
https://stackoverflow.com/questions/56301419
复制相似问题