1

https://gyazo.com/9f153457558977341c95019206010e00 This is the one text I want to store in a variable from the website. How do I do that? This is what I came up with:

text = browser.find_elements_by_css_selector('.vip-additional-text > *:nth-child(1) > p')
print(text)

output:

[]

It returns an empty list for some reason, can anyone help me please?

1 Answer 1

1

If you want the text and not the webElement you should try:

text = browser.find_element_by_class_name("vip-additional-text").text
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, but what if I only wanted the first. line, the first <p> "some text in here</p>
No problem ;) yes it can be done... I don't have a working example right now in python, but it's a subject for a different question with more details...
The code you showed me prints it all out on the side. I only wanted the first line. How do I all the other stuff apart from it?
You need to parse the text to get what you want, for example if you want only the first line it's something like: text.splitlines()[0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.