#!/usr/bin/env python # coding: utf-8 # ## Make a new Gateways (`_pass2journal`) # In[1]: from gummy.utils import get_driver from gummy import gateways from gummy.gateways import * # In[2]: gateway = gateways.get(input()) # #### Show Journals supported by Translation-Gummy # In[3]: gateway.supported_journals # #### Show Journals supported by Gateway Survice # In[4]: # from bs4 import BeautifulSoup # soup = BeautifulSoup(driver.page_source) # for aTag in soup.find(name="ul", class_="SS_DataBaseIndex").find_all(name="a"): # print(f"- {aTag.get_text()}: {aTag.get('href')}") # ### Create `_pass2journal` # - ex) NEJM: https://www.nejm.org/ # In[5]: driver = get_driver() driver = gateway._passthrough_base(driver) # In[6]: driver.get("https://gateway.itc.u-tokyo.ac.jp/,DanaInfo=www.nejm.org,SSL") current_url = driver.current_url url, dana_info, _ = current_url.split(",") print(f""" * current_url: {current_url} * url : {url} * dana_info : {dana_info} """) # In[7]: def fmt_url_func(cano_url, *args, **kwargs): gateway_fmt_url = re.sub( pattern=r"^https?:\/\/www\.nejm\.org\/(doi\/.+)\/(.+)$", repl=fr"{url}\1/,{dana_info},SSL+\2", string=cano_url ) return gateway_fmt_url # In[8]: cano_url = "https://www.nejm.org/doi/full/10.1056/NEJMcpc1913472" gateway_fmt_url = "https://gateway.itc.u-tokyo.ac.jp/doi/full/10.1056/,DanaInfo=www.nejm.org,SSL+NEJMcpc1913472" # In[9]: assert gateway_fmt_url == fmt_url_func(cano_url=cano_url) # In[ ]: