【Python】endote参考文献格式获取,从PubMed

自己建立个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

# 设置Chrome选项
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('--headless')  # 启用无头模式(可选)
options.add_argument('--window-size=1920x1080')  # 设置窗口大小(可选)
options.add_argument('--disable-gpu')  # 禁用GPU加速(可选)

# 读取CSV文件
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:
    # 初始化WebDriver
    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)
    #input()
    #driver.quit()  # 确保每次循环结束后都正确关闭浏览器实例

查看下载的,可以直接导入endnote

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值