-->

xpath in =importXML() for extracting meta descript

2020-07-22 19:22发布

问题:

I'm trying to use Xpath to pull in the meta descriptions from web pages, using Google Sheets.

I have this working to pull in the titles: =importXml(www.example.com; "//title")

Here are two sources of my learning:

http://seogadget.co.uk/playing-around-with-importxml-in-google-spreadsheets/
http://docs.google.com/support/bin/answer.py?hl=en&answer=75507

I have read many other posts on this site, and this seems to be the similar idea of what I want:

"/html/head/meta[@name='description']/@content"
"/*/head/meta[@name='description']/@content"
"//head/meta[@name=\"description\"]/@content"

None of these work in Google Sheets, which specifies to write it in Xpath. The only difference, is that in Google Sheets you are to use ' in place of " (hence why description is like that). I've honestly tried it about 219 different ways....no luck.

Any ideas? Thanks in advance!

回答1:

//meta[@name='description']/@content

So your full URL call in google sheet would be

=importxml(A1,"//meta[@name='description']/@content")

I've built some awesome SEO tools using importXML - this is just the start of it mate! :)