F
F
freiqq2020-01-06 23:06:37
Python
freiqq, 2020-01-06 23:06:37

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)

-------------------------------------------------- -------------------------------------------------- ----
"c:/Users/zzz/Desktop/Danil/programm/parsers/parserHawkBets2K.2.py", line 78, in
container = driver.find_element_by_css_selector('div.page_layout.match_page').get_attribute('innerHTML ')
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 598, in find_element_by_css_selector
return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\ remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local- packages\Python37\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\ site-packages\urllib3\request.py", line 80, in request
method, url, fields=fields, headers=headers, **urlopen_kw
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python. 3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\request.py", line 171, in request_encode_body
return self.urlopen(method, url,**extra_kw)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\poolmanager.py", line 330, in urlopen
response = conn. urlopen(method, u.request_uri, **kw)
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool. py", line 760, in urlopen
**response_kw
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py ", line 760, in urlopen
**response_kw
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 760, in urlopen
**response_kw
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\urllib3\connectionpool.py", line 720, in urlopen
method, url, error =e, _pool=self, _stacktrace=sys.exc_info()[2]
File "C:\Users\zzz\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages \urllib3\util\retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='(my host)', port=(my port): Max retries exceeded with url: /hub/session/b143eca0-3bf4-4b1c-9aa4-0e7f2f85386e/element (Caused by NewConnectionError (': Failed to establish a new connection: [WinError 10048] Usually only one use of socket address (protocol/network address/port)') is allowed)
PS C:\Users\zzz\Desktop\Danil\programm\parsers>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-01-06
@freiqq

not enough code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question