Reputation: 1
I am trying to get only the number of likes from a website. Currently, I am using
=IMPORTXML("https://www.abillionveg.com/articles/vegan-diet-nutrition-guide","//button")
However, it gives me data from all of the buttons. Can someone help me modify the formula to show only the likes? Sorry if this is a basic question, I am just learning.
Upvotes: 0
Views: 696
Reputation: 201643
You want to retrieve the number of the number of likes
using IMPORTXML
.
If my understanding is correct, how about this answer?
=INDEX(SPLIT(IMPORTXML(A1,"//div[@class='ArticleActions__Container-sc-15ye7g8-0 huWdyg'][1]//span[contains(text(),'likes')]")," "),1)
https://www.abillionveg.com/articles/vegan-diet-nutrition-guide
is put in the cell "A1".//div[@class='ArticleActions__Container-sc-15ye7g8-0 huWdyg'][1]//span[contains(text(),'likes')]
.IMPORTXML
.###
from the value like ### likes
using SPLIT
and INDEX
.=REGEXEXTRACT(IMPORTXML(A1,"//script[@id='__NEXT_DATA__']"),"likesCount""\:(\d+)") - 1
=IMPORTXML(A1,"//div[@class='ArticleActions__Container-sc-15ye7g8-0 huWdyg'][1]//span[contains(text(),'likes')]")
is used, 100 likes
is retrieved.Upvotes: 1