我正在编写一个解析器bot,它通过whois服务检查站点的域名。在终端中,解析过程正常,信息显示出来,但当需要在聊天中发送此文本时,会生成一个错误(send_message()缺少1个必需的位置参数:“text”)
这只是一个链接检查:
@bot.message_handler(commands=['getpng'])
def get_screenshot(message):
@bot.message_handler(commands=['getpng'])
def get_screenshot(message):
uid = message.chat.id
url = ""
try:
url = message.text.split(' ')[1]
except IndexError:
bot.send_message(uid, 'You have not entered URL!')
return
if not validators.url(url):
bot.send_message(uid, 'URL is invalid!')
else:
**this is the problematic part of the code:**
browser = webdriver.Chrome()
browser.get('https://www.nic.ru/whois/')
input1 = browser.find_element_by_xpath('//*[@id="rc-web-client"]/div/div/div[1]/main/div[1]/div[1]/div/div/div/input')
input1.send_keys(url)
time.sleep(2)
button = browser.find_element_by_xpath('//*[@id="rc-web-client"]/div/div/div[1]/main/div[1]/div[1]/div/button/span[1]')
button.click()
time.sleep(5)
infa = browser.find_element_by_xpath('//*[@id="rc-web-client"]/div/div/div[1]/main/div[1]/div[4]/div/div[2]/a[1]')
infa1 = infa.text
#print(infa1)
bot.send_message(infa1)
当我运行代码时,我会遇到这个错误。
为什么infa1中的文本不可见?我怎样才能解决这个问题
UPD:
Возникло исключение: TypeError (note: full exception trace is shown but execution is paused at: get_screenshot)
send_message() missing 1 required positional argument: 'text'
File "C:\Users\Petyal\Desktop\something.py", line 41, in get_screenshot (Current frame)
bot.send_message(infa1)
File "C:\Users\Petyal\Desktop\something.py", line 56, in <module>
bot.infinity_polling()
我想您错过了send_message函数中的chat_id参数
尝试添加一个参数:
相关问题 更多 >
编程相关推荐