给我一篇文章的DOI地址,例如:'https://doi.org/10.1093/qje/qjr041' 怎样才能得到对应的域特定URL或域名('https://academic.oup .com/') 来自使用 Python 3.0+ 的 DOI?
您可以使用 requests 模块并允许重定向来执行此操作。
举个粗略的例子
import requests
from urllib.parse import urlparse
URL = "https://doi.org/10.1093/qje/qjr041" # Specify the DOI here
r = requests.get(URL,allow_redirects=True) # Redirects help follow to the actual domain
parsed_uri = urlparse(r.url) #url parse to get the scheme and domain name
result = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_uri)
print(result) # printing the result
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句