0
0 комментариев

[apcode language=\»python\»]

# -*- codecs: utf-8 -*-
import codecs
import requests
from bs4 import BeautifulSoup
import selenium
from selenium import webdriver
import csv
  def main():
         url = \'https://1xstavka.ru/live/Football/\'
    driver = webdriver.Chrome()
    driver.get(url)    
    soup = BeautifulSoup(driver.page_source, \'html.parser\')   #driver.page_source
    containers = soup.findAll(\'div\', class_=\'c-events__item c-events__item_col\')
    for container in containers:
        teams = [x.get_text() for x in container.findAll(\'div\', class_=\'c-events__team\')] 
        odds = [x.get_text() for x in container.find_all(\'a\', class_=\'c-bets__bet\')]
    data = {\'teams\': teams,
                \'odds\': odds}
              with open(\'odds.csv\', \"w\", newline=\"\") as file:
        writer = csv.writer(file)
        writer.writerows((data[\'teams\'],
                         data[\'odds\']))               
          if __name__ == \'__main__\':
    main()

[/apcode]

Отменить выбор ответа
Добавить комментарий