Python SkypeWebClient-Bot with Selenium (Error 10048)

冷暖自知 提交于 2020-01-03 03:06:20

问题


I am building a bot for the skype web client (https://web.skype.com/en) using Selenium. Everything works like a charm but after a few moments I am getting the error 10048:
Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted

I checked netstat -n and saw that my programm creates a huge amount of connections.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
#driver = webdriver.Chrome(executable_path='c:\Python34\chromedriver.exe')
driver = webdriver.Firefox(executable_path='c:\Program Files\MozillaFirefox\firefox.exe')
driver.get("https://web.skype.com/de/")
time.sleep(8)
login = driver.find_element_by_id("username")
login.send_keys("username")
password = driver.find_element_by_id("password")
password.send_keys("password" + Keys.RETURN)
time.sleep(15)
newest2 = ""
sending = driver.find_element_by_name("messageInput")
message = driver.find_element_by_xpath("//*[@id='chatComponent']/div/swx-navigation/div/div/div/swx-chat-log/div[2]")
while 1==1 :
    newest = message.get_attribute("textContent")
    print(newest)
    if newest2 != newest:
        if '!reactionTest' in newest:
            sending.send_keys("Check" + Keys.RETURN)
    newest2 = newest
print("done")

I think that each time I call newest = message.get_attribute("textContent") a new connection is created. Because when I am not using the message element which always shows the newest message I am not encountering the problem. I can't seem to find a solution on google regarding this problem including selenium. Isn't there any way to close each connection at the end of the infinite loop? Any help is greatly appreciated :)


回答1:


I think you forgot for driver.close(). That's why you get huge amount of connections



来源:https://stackoverflow.com/questions/32721135/python-skypewebclient-bot-with-selenium-error-10048

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!