給我一篇文章的DOI地址,例如:'https://doi.org/10.1093/qje/qjr041' 怎樣才能得到對應的域特定URL或域名('https://academic.oup .com/') 來自使用 Python 3.0 的 DOI?
uj5u.com熱心網友回復:
您可以使用 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
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/465643.html
標籤:python-3.x dns 土井
上一篇:使用點格式時預期陳述句結束
