0

How can I print "Saturday 8th of February 2020 07:46:40 PM CDT"? I have googled a lot and tried many times. Can someone help me?

3

2 Answers 2

1

Kindly, DO NOT paste an HTML code as IMAGE within your future question, To make it easier, Please post the HTML as a code.

from bs4 import BeautifulSoup

html = """<div class="date">
<span title="Hi">Bye</span>
</div>"""


soup = BeautifulSoup(html, 'lxml')
print(soup.select_one('.date>span')['title'])

Output:

Hi
Sign up to request clarification or add additional context in comments.

Comments

0

You will have to use get_attribute method which is available in Selenium.

title_value = driver.find_element_by_xpath("//div[@class = 'date']/span[@title]").get_attribute('title')
print(title_value)

4 Comments

Based on what you providing an answer for Selenium as the OP didn't mentioned that he's using selenium at all?
@αԋɱҽԃαмєяιcαη : it is tagged my friend :)
we aren't supposed to guess from tag :D as bs4 is tagged as well. :D and Python wide selection.
Well you might have guessed as well since your answer us in bs4.

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.