Reputation: 23
I am trying to get the date of the tweet using the following code
div_class="css-901oao r-18jsvk2 r-37j5jr r-a023e6 r-16dba41 r-rjixqe r-bcqeeo r-bnwqim r-qvutc0
page = driver.page_source
soup = BeautifulSoup(page, "html.parser")
contents = soup.find_all(class_=div_class)
for p in contents:
print(p.time)
but None is printed
Upvotes: 0
Views: 239
Reputation: 25073
Provided that the element is included in your soup
- Classes look high dynamic so better change your selection strategy and use more static id, HTML structure, attriutes.
Following css selector
selects all <time>
that is an directly child of an <a>
:
for t in soup.select('a>time'):
# tag / element
print(t)
# text
print(t.text)
# attribute value
print(t.get('datetime))
Upvotes: 1