问题描述
限时送ChatGPT账号..我正在为 Skype 网络客户端构建一个机器人 (https://web.skype/en一>)使用硒.一切都像一个魅力,但过了一会儿,我收到错误 10048:
地址已被使用.通常每个套接字地址(协议/IP 地址/端口)只允许使用一次
I am building a bot for the skype web client (https://web.skype/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
我检查了 netstat -n,发现我的程序创建了大量连接.
I checked netstat -n and saw that my programm creates a huge amount of connections.
from selenium import webdriver
from selenium.webdrivermon.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/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")
我认为每次调用 newest = message.get_attribute("textContent")
一个新的连接被创建.因为当我不使用总是显示最新消息的消息元素时,我没有遇到问题.我似乎无法在谷歌上找到关于这个问题的解决方案,包括硒.有没有办法在无限循环结束时关闭每个连接?非常感谢任何帮助:)
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 :)
推荐答案
我想你忘记了 driver.close().这就是您获得大量连接的原因
I think you forgot for driver.close(). That's why you get huge amount of connections
这篇关于带有 Selenium 的 Python SkypeWebClient-Bot(错误 10048)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论