别再手动收藏了!我写了个Python脚本,自动抓取CVPR/ICCV/ECCV等顶会最新论文链接

张开发
2026/4/21 21:24:16 15 分钟阅读

分享文章

别再手动收藏了!我写了个Python脚本,自动抓取CVPR/ICCV/ECCV等顶会最新论文链接
用Python自动化抓取计算机视觉顶会论文从爬虫编写到定时推送每次CVPR、ICCV这些顶会放榜朋友圈总被论文链接刷屏。作为研究者手动收集这些论文不仅耗时还容易遗漏重要工作。去年CVPR2023放榜时我花了整整两天时间整理论文列表结果发现同行早已用自动化脚本完成了分类和初筛——那一刻我决定彻底告别手工操作。本文将分享一个完整的Python解决方案从爬取OpenReview、CVF等网站的最新论文到自动生成Markdown报告并推送到Notion或邮箱。这个系统已经稳定运行了一年多成功抓取了CVPR2024、ICLR2024等会议的上千篇论文。更重要的是所有代码都经过反爬处理优化即使网站改版也能快速适配。1. 环境准备与核心工具链在开始编写爬虫前需要搭建一个轻量但可靠的工具链。我推荐使用conda创建独立环境避免依赖冲突conda create -n paper_crawler python3.9 conda activate paper_crawler pip install requests beautifulsoup4 selenium markdown2 notion-client schedule这套组合拳中RequestsBeautifulSoup处理静态页面Selenium应对动态加载Markdown2用于格式转换Notion客户端实现自动同步Schedule则负责定时任务。对于需要登录的网站如OpenReview建议额外配置import os from dotenv import load_dotenv load_dotenv() # 加载.env文件中的认证信息 OPENREVIEW_USER os.getenv(OPENREVIEW_USER) OPENREVIEW_PWD os.getenv(OPENREVIEW_PWD)常见踩坑点某些会议网站使用Cloudflare防护直接请求会返回403OpenReview的页面结构每年都有微调需要动态适配CVF网站从2023年开始对高频访问实施限流2. 爬虫核心架构设计一个健壮的论文爬虫应该采用模块化设计便于维护和扩展。以下是核心类结构class ConferenceSpider: def __init__(self, year, save_dirpapers): self.year year self.save_dir save_dir os.makedirs(save_dir, exist_okTrue) def fetch_html(self, url): # 实现带重试机制的请求逻辑 pass def parse_papers(self, html): # 解析论文列表的抽象方法 raise NotImplementedError def run(self): html self.fetch_html(self.base_url) return self.parse_papers(html) class CVPRSpider(ConferenceSpider): property def base_url(self): return fhttps://openaccess.thecvf.com/CVPR{self.year}?dayall def parse_papers(self, html): # 实现CVPR特有的解析逻辑 soup BeautifulSoup(html, html.parser) papers [] for dt in soup.select(dt.ptitle): title dt.a.text.strip() link urljoin(self.base_url, dt.a[href]) papers.append({title: title, link: link}) return papers针对不同会议网站的特点需要定制解析策略会议平台解析难点解决方案OpenReview动态加载登录墙Selenium模拟用户操作CVF分页反爬机制随机延迟UserAgent轮换Springer复杂URL结构多层URL解析ICML官网混合了Workshop和Main TrackCSS选择器精准定位实战技巧遇到动态内容时先用浏览器开发者工具观察XHR请求往往能发现隐藏的API接口。比如ICLR2024的论文数据实际是通过以下接口获取API_URL https://api.openreview.net/notes?invitationICLR.cc/2024/Conference/-/Blind_Submission3. 反爬策略与鲁棒性优化顶会网站普遍对爬虫有所防范需要采取一系列反反爬措施。以下是经过验证的有效方案请求伪装headers { User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7), Referer: https://openaccess.thecvf.com/, Accept-Language: en-US,en;q0.9 }访问节奏控制import random from time import sleep def random_delay(): sleep(random.uniform(1.5, 3.0)) # 随机延迟1.5-3秒IP轮换方案适用于大规模抓取import requests from itertools import cycle proxies cycle([ {http: http://proxy1:port}, {http: http://proxy2:port} ]) def safe_request(url): current_proxy next(proxies) try: return requests.get(url, proxiescurrent_proxy, timeout10) except: return safe_request(url) # 自动重试自动适配页面改版def parse_with_fallback(html): # 尝试新版页面结构 try: return parse_new_layout(html) except Exception as e: print(f新版解析失败: {e}, 尝试旧版解析) return parse_old_layout(html)重要提示严格遵守网站的robots.txt规则设置合理的请求间隔。我曾因过于频繁访问导致IP被封后来通过添加time.sleep(5)解决了问题。4. 自动化工作流与持续集成完整的自动化系统应该包含以下组件定时触发模块import schedule import time def daily_check(): if is_conference_updated(): run_spiders() schedule.every().day.at(09:00).do(daily_check) while True: schedule.run_pending() time.sleep(60)数据存储方案对比存储方式优点缺点Markdown人类可读版本控制友好不利于复杂查询Notion数据库可视化强支持多维过滤API调用有限流SQLite查询高效支持复杂分析需要额外解析工具CSV通用性强Excel可直接打开缺乏层次结构Notion自动同步示例from notion_client import Client notion Client(authos.environ[NOTION_TOKEN]) def upload_to_notion(papers, database_id): for paper in papers: notion.pages.create( parent{database_id: database_id}, properties{ Title: {title: [{text: {content: paper[title]}}]}, URL: {url: paper[link]}, Conference: {select: {name: CVPR2024}} } )邮件通知模板import smtplib from email.mime.text import MIMEText def send_email(new_papers): msg MIMEText(f新增{len(new_papers)}篇论文\n\n \n.join( f- {p[title]}: {p[link]} for p in new_papers)) msg[Subject] f[论文追踪] {conference} 新增论文提醒 smtp smtplib.SMTP(smtp.gmail.com, 587) smtp.starttls() smtp.login(EMAIL_USER, EMAIL_PWD) smtp.sendmail(EMAIL_USER, TO_EMAILS, msg.as_string()) smtp.quit()5. 高级技巧与异常处理在长期运行中我总结出几个提升稳定性的关键点页面解析的健壮性改进def safe_extract(element, selector, default): try: return element.select_one(selector).text.strip() except AttributeError: return default自动重试机制from tenacity import retry, stop_after_attempt, wait_exponential retry(stopstop_after_attempt(3), waitwait_exponential(multiplier1, min4, max10)) def fetch_with_retry(url): response requests.get(url, headersheaders) response.raise_for_status() return response验证码处理方案极端情况if captcha in response.text: captcha_solution solve_captcha_manually() params {captcha: captcha_solution} response session.post(url, dataparams)日志监控系统import logging logging.basicConfig( filenamepaper_crawler.log, levellogging.INFO, format%(asctime)s - %(levelname)s - %(message)s ) try: spider.run() except Exception as e: logging.error(f抓取失败: {str(e)}, exc_infoTrue) send_alert_email(f爬虫异常: {str(e)})这套系统在CVPR2024期间成功抓取了全部2,357篇论文平均每天自动更新3次相比手动操作节省了约40小时的工作时间。最令人惊喜的是通过配置关键词过滤如diffusion、LLM它能自动高亮我感兴趣的研究方向。

更多文章