-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpages.py
More file actions
99 lines (66 loc) · 2.13 KB
/
pages.py
File metadata and controls
99 lines (66 loc) · 2.13 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
""" The page superclass and subclasses for verifier"""
from bs4 import BeautifulSoup
from settings import base_urls
import os
MIRROR = 'archive/'
# Superclass for page-specific page instances
class Page:
def __init__(self, url):
self.url = url
self.path = self.get_path_from_url(url)
# Set size attribute in KB, inherently checks if file exists
try:
self.file_size = os.path.getsize(self.path) / 1000
except FileNotFoundError:
raise FileNotFoundError
def __str__(self):
return self.path
# Takes a URL and produces its relative file name.
def get_path_from_url(self, url):
# Remove http://domain
tail = url.replace(base_urls[0], '') + 'index.html'
path = MIRROR + tail
return path
def get_content(self):
soup = BeautifulSoup(open(self.path), 'html.parser')
return soup
# Page-specific subclasses
class ProjectDashboardPage(Page):
def __init__(self, url):
super().__init__(url)
class ProjectFilesPage(Page):
def __init__(self, url):
super().__init__(url)
class ProjectWikiPage(Page):
def __init__(self, url):
super().__init__(url)
class ProjectAnalyticsPage(Page):
def __init__(self, url):
super().__init__(url)
class ProjectRegistrationsPage(Page):
def __init__(self, url):
super().__init__(url)
class ProjectForksPage(Page):
def __init__(self, url):
super().__init__(url)
class RegistrationDashboardPage(Page):
def __init__(self, url):
super().__init__(url)
class RegistrationFilesPage(Page):
def __init__(self, url):
super().__init__(url)
class RegistrationWikiPage(Page):
def __init__(self, url):
super().__init__(url)
class RegistrationAnalyticsPage(Page):
def __init__(self, url):
super().__init__(url)
class RegistrationForksPage(Page):
def __init__(self, url):
super().__init__(url)
class UserProfilePage(Page):
def __init__(self, url):
super().__init__(url)
class InstitutionDashboardPage(Page):
def __init__(self, url):
super().__init__(url)