forked from IEM-Computer-Vision/ICCV19-Paper-Review
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme_gen.py
46 lines (29 loc) · 1.42 KB
/
readme_gen.py
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
42
43
44
45
46
from bs4 import BeautifulSoup
import requests
import re
# Total Papers available on the website = 1075
paper_url = "http://openaccess.thecvf.com/ICCV2019.py"
domain = "http://openaccess.thecvf.com/"
review_domain = "https://{{site.github.owner_name}}.github.io/ICCV19-Paper-Review/"
paper_data = {} # {'title' : ('pdf link', 'review link')}
paper_index_start = 13
papers_todo = 10
response = requests.get(paper_url)
soup = BeautifulSoup(response.text, 'html.parser')
titlebox = soup.findAll('dt', attrs={'class': 'ptitle'})
dd_box = soup.findAll('dd')
pdfBox_index = 1
for titleboxes in titlebox:
title = titleboxes.find('a').contents[0]
title = re.sub(r"[^a-zA-Z0-9]+", '_', title) # Removing special Characters.
pdf_link = domain + dd_box[pdfBox_index].find('a')['href'] # parse paper link
review_link = review_domain + title # Generate Review Link
paper_data[title] = (pdf_link, review_link) # Add data to dictionary
pdfBox_index += 2
# Generate review paper markdown files and Update Readme
for title, links in list(paper_data.items())[paper_index_start : paper_index_start + papers_todo]:
review_paper = open(title+'.md', 'w')
review_paper.close()
readme_query = f"| {title.replace('_', ' ')} | [PDF Link]({links[0]}) | [Review Link]({links[1]}) | |"
with open('README.md', 'a') as readme_file:
readme_file.write(readme_query+'\n')