A
A
Aleksandr2019-05-22 08:17:01
Python
Aleksandr, 2019-05-22 08:17:01

Why is it showing only one result?

Hello. There is a parser that displays the result in the form of links in a telegram message.
But the difficulty is that I don't understand why it gives only one link, it should at the moment 3
Here is the complete code

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
import telebot;
bot = telebot.TeleBot('')
from telebot import apihelper
apihelper.proxy ={'https':'socks5://'}
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
  opts = Options()
  opts.headless=  True 
  assert opts.headless  
  browser = Firefox(options=opts)
  browser.get('https://')
  usr = ""
  pwd = ""
  username = browser.find_element_by_name("USER_LOGIN")
  username.send_keys(usr)
  password = browser.find_element_by_name("USER_PASSWORD")
  password.send_keys(pwd)
  browser.find_element_by_name('Login').click()
  browser.find_element_by_xpath("//td[text()='Изменено']/following-sibling::td[1]").click() 
  browser.find_element_by_xpath("//select[@name = 'LAMP[]']/option[@value = '']").click()
  browser.find_element_by_xpath("//select[@name = 'LAMP[]']/option[@value = 'yellow']").click()
  browser.find_element_by_xpath("//select[@name = 'CLOSE']/option[@value = 'N']").click()
  browser.find_element_by_name('filter').click()
  vrn = browser.find_elements_by_xpath("//td[text()='36']/following-sibling::td[2]")
  numberT = browser.find_elements_by_xpath("//*[@id='ticket_grid']/following-sibling::td[4]")
  if message.text == "Заявки":
    for x in vrn:
      complite = "Список заявок: " + "https:_ticket_" + x.text + ".php"
      bot.send_message(message.from_user.id, complite)
      browser.close()
      quit()
  else:
        browser.close()
        quit()
bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2019-05-22
@QQQ-RRR

And why close the browser and exit at the very first iteration of the loop through the found elements?...
Remove all this disgrace at the end instead of else

if message.text == "Заявки":
    for x in vrn:
      complite = "Список заявок: " + "https:_ticket_" + x.text + ".php"
      bot.send_message(message.from_user.id,  complite)

browser.close()
quit()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question