The script does not load data from the site into the CSV file that created it. Where is the problem?
from bs4 import BeautifulSoup as Soup from urllib.request import urlopen from collections import Counter import re import csv PAGENUMBER = 4 ARAWDATA = [] BRAWDATA = [] OFFICIALDATA = {} NUMBERS = [] TIMES = [] CHANCE = [] zc = 0 while PAGENUMBER <=1: # Our way of filtering through pages COUNTER = 0 # We will need this later url = urlopen('https://www.stoloto.ru/4x20/archive/ {}'.format(PAGENUMBER)) RAW = url.read() # Reads data into variable url.close() # Closes connection PARSED = Soup(RAW, 'html.parser') # (DATA, Type of Parser) for line in PARSED.findAll('div', attrs = {"class":"numbres","class":"numbers_wrapper","class":"container.cleaered" }): if 'stoloto.ru/4x20/archive' in str(line): # Checks if tag has those char pRAW = re.findall('d=(.*?)\">', str(line)) # Gathers only the dates from that text for pline in pRAW: ARAWDATA.append(pline) # Stores data in list for mutation later for line in PARSED.findAll('div', attrs = {"class":"numbres","class":"numbers_wrapper","class":"container.cleaered" }): if '<strong>' in str(line) and 'wrap' in str(line): # Needs to be setup this long way pRAW = re.findall('<b>(.*?)</b>', str(line)) for pline in pRAW: BRAWDATA.append(pline.replace(" · ", " ")) for date in ARAWDATA: OFFICIALDATA[date] = BRAWDATA[COUNTER] # For every date it will give it value of the numbers COUNTER += 1 PAGENUMBER += 1 with open('lotto.csv', 'w') as data: file = csv.writer(data) file.writerows(OFFICIALDATA.items())
open('rs.html', 'wb').write(RAW)in the code and look at thers.htmlfile make sure that you have the data you need 2) To check the question of ajax there is another way on that site open developer tool (for example, through F12), refresh the page and see which requests go - gil9red