Answer the question
In order to leave comments, you need to log in
How can I solve the error [WinError 10048]?
I suffer for 4 days with an error, I tried to solve it myself - nothing happened. Learning to write parsers for about a week
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from socket import *
import os
from multiprocessing import Pool, cpu_count
from time import ctime
HOST = "localhost"
PORT = ('мой порт') # Port number was changed here
BUFSIZE =1024
ADDRESS = (HOST, PORT)
capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities['marionette'] = False
driver = webdriver.Firefox(capabilities=capabilities)
driver.get('https://hawkbets.com/matches/recent')
time_list = []
try:
elements = driver.find_elements_by_css_selector('a.wrap') #Открывает матч
elements[0].click()
chk = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.gold_advantage_wrap")))
except IndexError:
print('there are no matches at the moment')
os.abort()
def track(container):
soup = BeautifulSoup(container, 'html.parser')
page =soup.select('main')
names = soup.select('div.teams')
chk = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "div.gold_advantage_wrap"))) #Ожидает появления селекторов
for elements_page in page:
gold = elements_page.select_one('b') # Ищет элемент преемущества и выводит
gold = gold.text.strip()
time = elements_page.select_one("div.championship_time") #то же самое,но уже с временем
time = time.text.strip()
time_k = list(time)
for i in time_k: #ДОРАБОТАТЬ преобразует время
if i.isdigit():
if len(time_list) < 5:
time_list.append(i)
else:
time = 0
if len(time_list) == 3:
time_list.insert(1,':')
elif len(time_list) == 4:
time_list.insert(2,':')
time = ''.join(time_list)
if int(gold) >= 20: #Проверяет золото
print('gold',gold)
print('time', time)
temp_hash = 0
while True:
container = driver.find_element_by_css_selector('div.page_layout.match_page').get_attribute('innerHTML')
if temp_hash != hash(container):
track(container)
temp_hash = hash(container)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question