forked from waqaraqeel/lit_grabber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acm.py
executable file
·61 lines (44 loc) · 1.56 KB
/
acm.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
import sys
import requests
from bs4 import BeautifulSoup
URL = sys.argv[1]
try:
style = sys.argv[2].strip()
except:
style = "sessions"
def get_full_link(link):
return "/".join(URL.split("/")[:3]) + link
def get_paper_info(item):
title = item.select("h5.issue-item__title")[0].string.split("\n")[0]
title = title[:128].replace(" ", "_").replace("/", "")
link = item.select('a[data-title="PDF"]')
if link:
return title, get_full_link(link[0]["href"])
return None, None
def print_all_on_page(soup):
for item in soup.select("div.issue-item-container"):
name, link = get_paper_info(item)
if name:
print(f"{name} {link}")
page = requests.get(URL)
soup = BeautifulSoup(page.text, "html.parser")
if style == "simple":
print_all_on_page(soup)
if style == "seemore":
while True:
print_all_on_page(soup)
button = soup.select("div.proceedingsLazyLoad a")
if not button:
break
page = requests.get(get_full_link(button[0]["href"]))
soup = BeautifulSoup(page.text, "html.parser")
if style == "sessions":
headingCount = len(soup.select("div.sections div.rlist div.toc__section"))
for i in range(headingCount):
sessionName = soup.select("a#heading" + str(i + 1))[0].string.lower()
if "posters" in sessionName or "demos" in sessionName:
continue
page = requests.get(URL + "?tocHeading=heading" + str(i + 1))
soup = BeautifulSoup(page.text, "html.parser")
print_all_on_page(soup)