-
Notifications
You must be signed in to change notification settings - Fork 0
/
URLCollector.py
67 lines (55 loc) · 2.31 KB
/
URLCollector.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
62
63
64
65
66
67
import CharScrapper as CharScrapper
import os
import Helpers as helpers
import json
import CharClass as cc
import pickle as pickle
class UrlCollect(object):
def __init__(self):
self.name = "UrlCollect"
self.helo = helpers.Helpers()
def get_urls_file_loc(self):
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
self.urls_file = os.path.join(__location__, self.helo.get_campain(__location__) + '__URLS.UFS')
def CheckCurrentUrls(self):
helo = helpers.Helpers()
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
self.urls_file = os.path.join(__location__,self.helo.get_campain(__location__) + '__URLS.UFS')
path = self.helo.get_campain(__location__) + '__URLS.UFS'
pysonob = helo.load_picklefile(path)
print(pysonob)
return pysonob
def createUrlFile(self, path, data):
with open(path, "wb") as data_file:
pickle.dump(data, data_file)
def addUrls(self, urllist):
#pysonob = self.CheckCurrentUrls()
helo = helpers.Helpers()
self.get_urls_file_loc()
char_list = []
for url in urllist:
cs = CharScrapper.CharScrape()
charob = cs.CharScrape(url)
CharC = cc.CharClass()
CharData = CharC.CreateCharData(charob, url)
#CharData = helo.race_modify(CharData)
char_list.append(CharData)
for each in char_list:
print(each.name, each.url)
self.createUrlFile(self.urls_file, char_list)
print(self.urls_file)
def getUrls(self):
pysonob = self.CheckCurrentUrls()
for each in pysonob:
print(each.name)
def live_Pull(self):
pysonob = self.CheckCurrentUrls()
for each in pysonob:
print(each.name)
UC = UrlCollect()
UC.addUrls(["https://www.dndbeyond.com/character/4741434/json", "https://www.dndbeyond.com/character/15473396/json", "https://www.dndbeyond.com/character/10428007/json", "https://www.dndbeyond.com/character/15636899/json", "https://www.dndbeyond.com/character/10648918/json"])
#UC.getUrls()
#cs = CharScrapper.CharScrape()
#charob = cs.CharScrape("https://www.dndbeyond.com/character/2113653/json")
#print(charob['name'])
#cs.SaveCharScrape(charob)