python下载CVF论文

基于看论文需求,不想一篇篇点击跳转CVF顶会的论文,因此用python下载。(https://openaccess.thecvf.com/

github链接:https://github.com/FengJunJian/download_CVF

若不想跳转,代码如下:

import urllib.request
import re
import os
import argparse
parser=argparse.ArgumentParser(description='Input Conference (C) and Year (Y)')
parser.add_argument('C',type=str,default='CVPR',
                    help='a name of CVPR, ICCV or ECCV')
parser.add_argument('Y',type=int,default=2020,
                    help='the year of conference')
#parser.print_help()
args=parser.parse_args()

def getHtml(url):
    page = urllib.request.urlopen(url)
    html = page.read()
    html = html.decode('utf-8')
    return html

def download_file(download_url, file_name):
    response = urllib.request.urlopen(download_url)
    file = open(file_name, 'wb')
    file.write(response.read())
    file.close()
    print("Completed")

Conference=args.C#'ICCV'
Year=args.Y#2019
save_path = '%s%d'%(Conference,Year)# dir to save
if not os.path.exists(save_path):
    os.mkdir(save_path)
url = 'http://openaccess.thecvf.com/%s%d.py'%(Conference,Year)

html = getHtml(url)
compile_text=r'\b\?day=[0-9][0-9][0-9][0-9]\-[0-9][0-9]\-[0-9][0-9]\b'#正则化模式1匹配日子
compile_paper=r'\bcontent_.*paper\.pdf\b'#正则化模式
parttern = re.compile(compile_text)
url_list = parttern.findall(html)
paper_url_list=[]
if url_list.__len__()==0:
    parttern = re.compile(compile_paper)
    paper_url_list.extend(parttern.findall(html))
else:
    for suburl in url_list:
        html = getHtml(url +suburl)
        parttern = re.compile(compile_paper)
        url_temp = parttern.findall(html)
        paper_url_list.extend(url_temp)

for url in paper_url_list:
    name = url.split('/')[-1]
    file_name = os.path.join(save_path , name)
    download_file('http://openaccess.thecvf.com/'+url, file_name)

如有问题,请不吝指正!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值