簡體   English   中英

給定一篇文章的 DOI,如何使用 python 獲取域名?

[英]Given a DOI of an article, how can I get the domain name using python?

我得到了一篇文章的 DOI 地址,例如:'https://doi.org/10.1093/qje/qjr041' 如何獲得相應的特定域 URL 或域名('https://academic.oup .com/') 從那個 DOI 使用 Python 3.0+?

您可以使用請求模塊並允許重定向來執行此操作。

舉個粗略的例子

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM