I need to extract some URLS and their respective titles using Google Sheets ImportXML with Xpath.
I found these previous answers and tested them but they don't seem to be working for my case:
How do I return a specific link address using IMPORTXML and XPath
I tested these formulas:
=IMPORTXML("https://ok.ru/video/334044074277","//*[contains(@class, 'video-card_n-w')]//a/@href", "en_US")
=IMPORTXML("https://ok.ru/video/334044074277","//*[contains(@class, 'video-card_n-w')]/a/@title", "en_US")
href returns #
.
The xpaths seems correct on chrome developer tool.
EDIT1: title works now but not href.
EDIT2:
I tested this also but same #
result:
=IMPORTXML("https://ok.ru/video/334044074277","//*[contains(@class, 'video-card_n ellip')]/@href", "en_US")
.
if you run:
=IMPORTXML("https://ok.ru/video/c1458725","//@href")
you can see why are you getting #
try:
=INDEX(LET(x, "https://ok.ru", HYPERLINK(x&QUERY(
IMPORTXML(x&"/video/c1458725","//@href", "en_US"), "where Col1 matches '/video.*album'", ),
IMPORTXML(x&"/video/c1458725","//*[contains(@class, 'video-card_n ellip')]"))))