-
Notifications
You must be signed in to change notification settings - Fork 0
/
classVB.py
61 lines (54 loc) · 1.3 KB
/
classVB.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
from bs4 import BeautifulSoup as bs
import requests as req
class VB:
def __init__(self, url):
self.url = url;
self.soup = 'blank';
def retrieve(self):
try:
pyforum = req.get(self.url);
except:
return 'pyforum did not make request'
soup = bs(pyforum.text, 'html.parser')
self.soup = soup;
return soup.title;
def totals(self, obj, name):
stats = self.soup.find('ul', {'class': 'forum-stats-bits'})
children = stats.findChildren();
count = 0
for child in children:
if (count > 0):
# print(child.contents[0])
pass
if (count == 2):
num = list(child.contents[0])
truenum = []
for x in num:
if x != ',':
truenum.append(x)
strnumber = ''.join(truenum)
number = int(strnumber);
obname = name + "discussions"
obj[obname] = number
if (count == 4):
num = list(child.contents[0])
truenum = []
for x in num:
if x != ',':
truenum.append(x)
strnumber = ''.join(truenum)
number = int(strnumber);
obname = name + "messages"
obj[obname] = number
if (count == 6):
num = list(child.contents[0])
truenum = []
for x in num:
if x != ',':
truenum.append(x)
strnumber = ''.join(truenum)
number = int(strnumber);
obname = name + "members"
obj[obname] = number
count += 1
return obj;