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?
-
A simple googling: stackoverflow.com/questions/43005780/… Is this what you are looking for?asher– asher2021-07-01 17:33:43 +00:00Commented Jul 1, 2021 at 17:33
-
A simple googling: stackoverflow.com/questions/43005780/… Is this what you are looking for?asher– asher2021-07-01 17:35:58 +00:00Commented Jul 1, 2021 at 17:35
-
Please edit your code showing us what you have already tried. Providing a minimal, reproducible exampleMendelG– MendelG2021-07-01 17:38:49 +00:00Commented Jul 1, 2021 at 17:38
Add a comment
|
2 Answers
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
Comments
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
αԋɱҽԃ αмєяιcαη
Based on what you providing an answer for
Selenium as the OP didn't mentioned that he's using selenium at all?cruisepandey
@αԋɱҽԃαмєяιcαη : it is tagged my friend :)
αԋɱҽԃ αмєяιcαη
we aren't supposed to guess from tag :D as
bs4 is tagged as well. :D and Python wide selection.cruisepandey
Well you might have guessed as well since your answer us in bs4.
