forked from 51takahashi/AutoDownloadICCV2015
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAutoDownloadCVPR2020.py
More file actions
41 lines (36 loc) · 1.02 KB
/
AutoDownloadCVPR2020.py
File metadata and controls
41 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
"""
@author: 51takahashi
"""
import os
import requests
conf = 'CVPR2020'
header = 'http://openaccess.thecvf.com/'
def name_check(name):
name = name.replace('?','')
name = name.replace(':','')
name = name.replace('*','')
name = name.replace('/',' or ')
return name
def main():
if not os.path.exists(conf):
os.mkdir(conf)
r = requests.get(header+conf+'.py')
txt = r.text
lines = txt.split('\n')
cnt = 0
for line in lines:
if line.find('<dt class="ptitle">')>-1:
pdfname = conf+'/'+name_check(line.split('>')[3].split('<')[0])+'.pdf'
cnt+=1
if len(line)>0:
if line[0]=='[':
print(str(cnt)+':'+pdfname)
if not os.path.exists(pdfname):
url = header+line.split('"')[1]
r = requests.get(url)
f = open(pdfname, 'wb')
f.write(r.content)
f.close()
if __name__ == '__main__':
main()