I am looking to confirm the existence of a specific element. My approach is to print it out so that I can compare it with a string or another value.
Below is the code causing issues:
session = HTMLSession()
r = session.get('https://www.walmart.com/ip/Sony-PlayStation-5-Video-Game-Console/994712501')
r.html.render(timeout=20)# this call executes the js in the page
oos=r.html.xpath('/html/body/div[1]/div[1]/div/div[2]/div/div[1]/div[1]/div[1]/div/div/div/div/div[3]/div[5]/div/div[3]/div/div[2]/div[1]/section/div[2]/div/div/div/div/div')
print(oos)
#print returns []
When I try to print(oos.text)
, I encounter a callback error
#'list' object has no attribute 'text'
I also attempted print(oos.full_text)
but encountered the same error
'list' object has no attribute 'full_text'
It appears to be a list, so I decided to iterate through it:
for i in oos:
print(i)
#Prints absolutely nothing!