2024-09-30 12:16:23 发布
网友
我试图从这个website获取一些数据。我可以输入'text'和'longest'only'参数,但是当我传递'ontologys'参数时,它说没有JSON对象可以解码。这是完整的URL
参数是ontologies[],因为您可以指定多个参数。您的请求应该与online search使用的请求类似:
ontologies[]
text=lung+cancer%2Cbone+marrow&ontologies%5B%5D=NCIT&longest_only=true&raw=true
只需在那里执行相同的搜索,并使用您喜爱的浏览器的developer tools选项来检查实际发送的有效负载是什么。在
这不是一个答案,但我可以显示在执行示例代码时看到的错误的唯一位置。我将代码放在main中的一个新模块中,并在Python3.4中运行它。在
main
import requests if __name__ == '__main__': url = 'http://bioportal.bioontology.org/annotator' params = { 'text': 'lung cancer,bone marrow', 'ontologies': 'NCIT', 'longest_only': 'true' } session = requests.Session() session.get(url) response = session.post(url, data=params) data = response.json() # get the annotations for annotation in data['annotations']: print (annotation['annotatedClass']['prefLabel'])
我收到以下错误。在
参数是
ontologies[]
,因为您可以指定多个参数。您的请求应该与online search使用的请求类似:只需在那里执行相同的搜索,并使用您喜爱的浏览器的developer tools选项来检查实际发送的有效负载是什么。在
这不是一个答案,但我可以显示在执行示例代码时看到的错误的唯一位置。我将代码放在
main
中的一个新模块中,并在Python3.4中运行它。在我收到以下错误。在
^{pr2}$相关问题 更多 >
编程相关推荐