Hi @NazarovALAL, unfortunately YouTube doesn't provide the same HTML code you see when accessing the page through your browser, hence why the xpath clause fails to get the views. This happened to other users before and the code there is a bit out of date for that purpose but still valid as an example if you want to access an HTML through .xpath().
You can do a test by looking for an website where you get the same HTML by other means other than the browser (using curl or wget for example)
xmltodict
python module, you can have more details here: https://pypi.org/project/xmltodict
Kovan
0x1d241954e00599797de78a4030297f9e4c45b77a4f018e2ee68d748bb104017c
, just in case u need it for investigation. I also try the https://app.provable.xyz/home/check_query
but it unable to find my query. I am not sure if that tool only check for query on the main net?
function update() public payable
{
emit LogNewProvableQuery("Provable query was sent, standing by for the answer...");
currentID = provable_query("URL", 'html(https://www.youtube.com/watch?v=9bZkp7q19f0).xpath(//*[contains(@class, "watch-view-count")]/text())');
}
I just added the currentID
parameter to store the query id, the rest is the same as the sample code in YoutubeViews.sol
@nhatminh12369 - unfortunately that sample code is deprecated (we will mark as deprecated soon, since there are a lot of users reporting the same issue) because the youtube html page retrieved by our engine misses the html element containing the number of views.
You can check that yourself running this command
`curl https://www.youtube.com/watch?v=9bZkp7q19f0` -o youtube.html
and check the content of the youtube.html\
page.
We suggest you to run the test above before running the query in order to be 100% sure that the html element you're looking for exists inside the page.
unfortunately that sample code is deprecated
btw, thanks for letting me know, I didn't notice that an html element was missing