Extract test python-selenium

Question:

How can I extract numeric digits in Element HTLMthe text to copy it (CTRL + C) which changes every time, when the script is closed and reopened?

<span class="inSubject subject"> <a href=" www. example.com" title="" class="viewLink title-subject" data-example-id="92fjjkkla6a07ea9601d770b816f79b927c8a"> 5023ABCDEFSGILMOPW</a> </span> `

In this example the number to extract is: "5023"

Asked By: lolino

||

Answers:

Try this:

import re
import pyperclip

strrr = '5023ABCDEFSGILMOPW'

value = re.search('^d+', strrr)[0]

pyperclip.copy(value)

for pyperclip working, it should be installed with pip:

pip install pyperclip

or get more code description, where we can extract more info to help out

Answered By: Vova