Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from openpyxl import *
- from string import ascii_uppercase
- import itertools
- def iter_all_strings():
- for size in itertools.count(1):
- for s in itertools.product(ascii_uppercase, repeat=size):
- yield "".join(s)
- def excel_management(new_table):
- number, count = 1, 0
- try:
- excel_document = load_workbook('probets.xlsx')
- sheet = excel_document['Probets']
- data_management(new_table, number, count, sheet)
- excel_document.save('probets.xlsx')
- print('Done!')
- except Exception as e:
- print("Something Went Wrong...", e)
- def data_management(new_table, number, count, sheet):
- length_data_match = 20
- for i in range(len(new_table)):
- for s in iter_all_strings():
- pos = s + str(number)
- sheet[pos] = new_table[i]
- count += 1
- if count == length_data_match:
- number += 1
- count = 0
- data_management(new_table, number, count, sheet)
- def main():
- browser = webdriver.Chrome('C:\\Users\\Antonio\\Desktop\\chromedriver')
- url = 'https://www.asianbetsoccer.com/it/livescore.html'
- try:
- browser.get(url)
- except Exception as e:
- print("Something Went Wrong...", e)
- table = browser.find_element_by_id('tablematch2')
- new_table = table.text.split(" ")
- print(new_table)
- excel_management(new_table)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement