前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【工具】自动搜索Research网站的学术会议排名

【工具】自动搜索Research网站的学术会议排名

作者头像
小锋学长生活大爆炸
发布2023-08-09 17:24:38
1900
发布2023-08-09 17:24:38
举报

转载请注明出处:小锋学长生活大爆炸[xfxuezhang.cn]

Research.com是一个可以搜索学术会议网站的影响因子的网站。

好用是好用,但有一个缺点:得手动选择类目。有这么多类目,一个个手动选也太累了。

所以做了一个自动搜索的小工具,效果如图:

当然也是开源的,放到了这里:GitHub - 1061700625/small_tools_v2: 使用tkinter和Python制作的小工具集,非常方便自己扩展

这里也放一波源码,但不一定会常来更新,更新的还是放到上面的github去了:

代码语言:javascript
复制
import requests
from bs4 import BeautifulSoup
from tqdm import tqdm
import threading
import tkinter as tk
import tkinter.messagebox as msgbox
import tkinter.ttk as ttk
import tkinter.simpledialog as simpledialog

def search(keyword):
    filterDisciplines = [
        'animal-science-and-veterinary',
        'biology-and-biochemistry',
        'business-and-management',
        'chemistry',
        'computer-science',
        'earth-science',
        'ecology-and-evolution',
        'economics-and-finance',
        'electronics-and-electrical-engineering',
        'environmental-sciences',
        'genetics-and-molecular-biology',
        'immunology',
        'law-and-political-science',
        'materials-science',
        'mathematics',
        'mechanical-and-aerospace-engineering',
        'medicine',
        'microbiology',
        'neuroscience',
        'physics',
        'plant-science-and-agronomy',
        'psychology',
        'social-sciences-and-humanities',    
    ]

    results = []
    for target in tqdm(filterDisciplines, desc='挨个搜索中...', ncols=60):
        url = 'https://research.com/conference-rankings/' + target

        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82',
        }
        data = {"searchQuery": keyword}
        soup = BeautifulSoup(requests.post(url, json=data, headers=headers).text, 'lxml')
        
        conference_items = soup.find_all('div', class_='conference-item')
        if not conference_items:
            continue
        
        for item in conference_items:    
            rank = item.find(class_='position').getText().replace('Rank', '').strip()
            score = item.find(class_='rankings-info').getText().strip()
            url = item.find('a').get('href').strip()
            title = item.find('a').getText().strip()
            results.append((rank, title, score, url))
        break

    print('排名\t名称\t\t影响因子\t链接')
    for rank, title, score, url in results:
        print(f'{rank}\t{title}\t{score}\t{url}')

    return results


def on_button_click():
    processing = False
    def perform_search(keyword):
        nonlocal processing
        processing = True
        button.config(text="搜索中...", state=tk.DISABLED)
        
        # Clear the output list before performing the search
        output_listbox.delete(*output_listbox.get_children())

        if keyword is not None and len(keyword.strip()) > 0:
            keyword = keyword.strip()
            for rank, title, score, url in search(keyword):
                output_listbox.insert("", "end", values=(rank, title, score, url))
        processing = False
        button.config(text="开始搜索", state=tk.NORMAL)
    
    if not processing:
        keyword = input_entry.get()
        if not keyword.strip():
            msgbox.showinfo("Warning", "请先输入搜索词")
        else:
            t = threading.Thread(target=perform_search, args=[keyword,], daemon=True)
            t.start()

def on_treeview_double_click(event):
    item = output_listbox.selection()
    if item:
        selected_item = output_listbox.item(item, "values")
        if selected_item:
            link = selected_item[3]
            root.clipboard_clear()
            root.clipboard_append(link)
            msgbox.showinfo("Copy", f"Link copied: {link}")


# 粗糙版本,请勿模仿
root = None
output_listbox = None
input_entry = None
button = None
def process():
    global root, output_listbox, input_entry, button
    root = tk.Tk()
    root.title("Research-er")
    # Calculate the center position of the screen
    window_width = 400
    window_height = 300
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    x_position = (screen_width - window_width) // 2
    y_position = (screen_height - window_height) // 2
    root.geometry(f"{window_width}x{window_height}+{x_position}+{y_position}")


    input_entry = tk.Entry(root)
    input_entry.pack(pady=10)

    button = tk.Button(root, text="开始搜索", command=on_button_click)
    button.pack()

    columns = ("Rank", "Name", "Impact Factor", "Link")
    output_listbox = ttk.Treeview(root, columns=columns, show="headings")
    for col in columns:
        output_listbox.heading(col, text=col)
        output_listbox.column(col, width=100, anchor="center")
    output_listbox.pack(pady=10, fill=tk.BOTH, expand=True)

    # Add horizontal and vertical scrollbars to the output listbox
    h_scrollbar = ttk.Scrollbar(root, orient=tk.HORIZONTAL, command=output_listbox.xview)
    v_scrollbar = ttk.Scrollbar(root, orient=tk.VERTICAL, command=output_listbox.yview)
    output_listbox.configure(xscrollcommand=h_scrollbar.set, yscrollcommand=v_scrollbar.set)
    h_scrollbar.pack(fill=tk.X, side=tk.BOTTOM)
    v_scrollbar.pack(fill=tk.Y, side=tk.RIGHT)

    output_listbox.bind("<Double-Button-1>", on_treeview_double_click)

    root.mainloop()


if __name__ == '__main__':
    process()
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-08-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档