T
T
thescorpyt2020-12-03 06:40:30
Python
thescorpyt, 2020-12-03 06:40:30

How to extract specific text from an element?

For example, they write to me the word "Send "captcha 3333""
How can I send exactly this interval without quotes?

while True:
    t = browser.find_elements_by_xpath('//*[@id="content"]/div/div[1]/div[3]/div[2]/div[3]/div/div/div/div/div[1]/div')
    e = browser.find_element_by_xpath('//*[@id="content"]/div/div[1]/div[3]/div[2]/div[3]/div/div/div/div/div[1]/div[' + str(len(t)) + ']').text


elif 'Отправьте' in e:
        print(Fore.LIGHTCYAN_EX + 'КАПЧА!')
        browser.find_element_by_xpath('//*[@id="im_editable2000000175"]').send_keys('') + e.split(' «')[-1]
        browser.find_element_by_xpath('//*[@id="content"]/div/div[1]/div[3]/div[2]/div[4]/div[2]/div[4]/div[1]/button').click()
        break

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-12-03
@SoreMix

import re
s = 'Отправьте "капча 3333"'
print(re.search(r'"(.+?)"', s).group(1))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question