自己建立个csv文件,放文献
执行python代码
import csv
from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
options = webdriver.ChromeOptions()
options.add_experimental_option('useAutomationExtension', False)
options.add_experimental_option("excludeSwitches", ['enable-automation'])
options.add_argument('--start-maximized')
options.add_argument('disable-infobars')
options.add_argument('--window-size=1920x1080')
options.add_argument('--disable-gpu')
with open("endnote.csv", newline='') as csvfile:
reader = csv.reader(csvfile)
headers = next(reader)
column_name_1 = "v1"
index_1 = headers.index(column_name_1)
sci_list = [row[index_1] for row in reader]
print(sci_list)
for gonghao in sci_list:
driver = webdriver.Chrome(service=Service(r'D:\chromedriver\chromedriver.exe'), options=options)
driver.maximize_window()
login_url = 'https://pubmed.ncbi.nlm.nih.gov/'
driver.get(login_url)
wait = WebDriverWait(driver, 10)
username_input_xpath = "/html/body/div[2]/main/div[1]/div/form/div/div[1]/div/span/input"
username_field = wait.until(EC.presence_of_element_located((By.XPATH, username_input_xpath)))
username_field.clear()
username_field.send_keys(gonghao)
login_button_xpath = "/html/body/div[2]/main/div[1]/div/form/div/div[1]/div/button"
login_button = wait.until(EC.element_to_be_clickable((By.XPATH, login_button_xpath)))
login_button.click()
sleep(3)
cite_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, 'citation-button')))
cite_button.click()
citation_dialog = wait.until(EC.visibility_of_element_located((By.CLASS_NAME, 'citation-dialog')))
copy_button = citation_dialog.find_element(By.CLASS_NAME, 'download-title')
copy_button.click()
sleep(2)
print(1)
查看下载的,可以直接导入endnote