-1
I am using lxml
along with Python 3.8
and I’m needing to take the xpath of a text that’s inside that part of html:
<span class="text-down">7424.65</span>
The xpath is:
//*[@id="root"]/div/div/div[2]/div/div[3]/div[1]/div/div[2]/p[2]/span
I’m trying to use:
//*[@id="root"]/div/div/div[2]/div/div[3]/div[1]/div/div[2]/p[2]/span/text()
But just return to me: []
Can anyone tell me what I’m doing wrong? My code is this:
Pagina = requests.get('https://www.bitrue.com/trade/btc_usdt')
Pagina = html.fromstring(Bitrue_pagina.content)
Pagina_Valor = Bitrue_pagina.xpath('//*[@id="root"]/div/div/div[2]/div/div[3]/div[1]/div/div[2]/p[1]/text()')
print(Pagina_Valor)
It usually works on other elements, only I don’t know if it’s because this element is constantly updated (it’s not a fixed value) but it’s never getting it..
I found this How to pick up text from a span? but it is using Selenium, and the intention is to optimize the code, I do not want to spend time opening the browser
If anyone can inform me I’d be very grateful :)
Excellent, thank you very much for the support
– user3602803
A question: Where did you see the link that he makes the request ? I searched here and could not find
– user3602803
@user3602803 has to open the developer tools tab before loading the page, because requests are not saved before the tab is open, and this is done immediately after the page is loaded.
– Pedro von Hertwig Batista
But on which page of F12? Because I don’t see it in "Elements" or in "Console" =\
– user3602803
In the "Network tab".
– Pedro von Hertwig Batista