The HTML code is
<div class="_4w5j">
<strong>
<span>username</span>
</strong>
<span class="_-kj">—</span>
<span class="_4w5k">
<i class="img sp_4YfKd3lpYjo sx_5f57b1">
<u>5 star</u>
</i>
</span>
<span>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span>
</div>
- I need the text "username" inside strong/spam It is works for me the code is
x= i.find_elements_by_xpath('//div[@class="_4w5j"]/strong')
for d in x:
print d.text
It's print the correct result
I need the text of 'x'inside the span[3] 'xxxxxxxxxxxxxxx' the below code also works good.
Question:
I need the text inside the u tag '5 star'. I used the below code but it prints the empty result.
y= i.find_elements_by_xpath('//div[@class="_4w5j"]/descendant::u')
for d in y:
print d.text
I tried this also
y= i.find_elements_by_xpath('//div[@class="_4w5j"]/span[2]/i/u')
for d in y:
print d.text
Not working for me. Please help me . Thanks in advance
<a class="uiLinkSubtle" href="/sherryl.cheary/activity/10152833559161998">
<abbr class="timestamp" data-utime="1419713801" title="Saturday, December 27, 2014 at 12:56pm">about a month ago</abbr>
</a>
I need the text inside the title but the below code sh
z= i.find_elements_by_xpath('//a/descendant::abbr/@title')
for dd in z:
print dd.text
Its shows the error called " web element has no attr title or some thing wrong in xpath"
//span class='_4w5k'and then do element.text?//abbr[@class='timestamp']and then callget_attribute("title"). I have never worked in python, so please check the signature of get_attribute method. Thanks"//span[@class='_4w5k']". Just forgot to put square brackets.