Note that there are some explanatory texts on larger screens.

plurals
  1. POXPath query in Google docs does not match HTML source
    primarykey
    data
    text
    <p>Using <a href="http://www.xpathbuilder.com/" rel="nofollow">XpathBuilder</a> I can construct a simple search engine query and pull data out of the search results using XPath. I have some simple examples in a Google Doc spreadsheet <a href="https://docs.google.com/spreadsheet/ccc?key=0AtT1QPEACWUldE9CZno5WkhzVGZBXzhaMjdNc045Z3c" rel="nofollow">here</a>, which runs the query "XPath tutorial" on various search engines and attempts to pull out the number of results each search engine returns. </p> <p>The code in that Google Doc is as follows:</p> <pre><code>=importxml("http://www.google.com/search?q="xpath+tutorial"&amp;num=30&amp;pws=0", "//div[@id='resultStats']") =importxml("http://www.bing.com/search?q=xpath+tutorial&amp;count=30", "//span[@class='sb_count']") =importxml("http://search.yahoo.com/search?p=xpath+tutorial&amp;n=30", "//span[@id='resultCount']") </code></pre> <p>There are some oddities about this that I don't understand. Firstly, the Google search does not return any results, but the XPath query looks OK. Indeed, there are a number of online tutorials which recommend exactly what I have done here.</p> <p>The Yahoo query returns the correct result, it's the only one that does.</p> <p>The number of results found by the Bing Xpath query do not match the results given on the <a href="http://www.bing.com/search?q=xpath+tutorial&amp;count=30" rel="nofollow">Bing web page</a>, even though there is only one XML node which matches the XPath query. More details are on the <a href="https://docs.google.com/spreadsheet/ccc?key=0AtT1QPEACWUldE9CZno5WkhzVGZBXzhaMjdNc045Z3c" rel="nofollow">spreadsheet here</a></p> <p>Where did it all go so wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload