не работает парсер сайта
https://www.championat.com, что надо исправить? Вот мой код:
class xstavka:
host = 'https://www.championat.com/'
url = 'https://www.championat.com/football/_england/tournament/2995/'
lastkey = ""
lastkey_file = ""
def __init__(self, lastkey_file):
self.lastkey_file = lastkey_file
if(os.path.exists(lastkey_file)):
self.lastkey = open(lastkey_file, 'r').read()
else:
f = open(lastkey_file, 'w')
self.lastkey = self.get_lastkey()
f.write(self.lastkey)
f.close()
def new_matches(self):
r = requests.get(self.url)
html = BS(r.content, 'html.parser')
new = []
items = html.select('.tiles > .items > .item > a')
for i in items:
key = self.parse_href(i['href'])
if(self.lastkey < key):
new.append(i['href'])
return new
def get_lastkey(self):
r = requests.get(self.url)
html = BS(r.content, 'html.parser')
items = html.select('.tiles > .items > .item > a')
return self.parse_href(items[0]['href'])
def parse_href(self, href):
result = re.match(r'\/show\/(\d+)', href)
return result.group(1)
def update_lastkey(self, new_key):
self.lastkey = new_key
with open(self.lastkey_file, "r+") as f:
data = f.read()
f.seek(0)
f.write(str(new_key))
f.truncate()
return new_key