正如@MarcusRickert指出的那样,HTTPS页面可能是一个问题。使用他们的HTTP版本:
=IMPORTXML("http://www.google.com/search?tbm=shop&q=ipod+nano&gws_rd=ssl", "//h3")
结果(裁剪):
Apple iPod Nano (6th Generation) - 8 GB - Graphite
Apple iPod Nano (3rd Generation) - 4 GB - Silver
Apple iPod Nano (4th Generation) - 8 GB - Pink
Apple iPod Nano (PRODUCT) RED (7th Generation) - 16 GB - Red
Apple iPod Nano (2nd Generation) - 4 GB - Silver
Apple iPod Nano (5th Generation) - 8 GB - Black
Apple iPod Nano (4th Generation) - 8 GB - Silver
Apple iPod Nano (7th Generation) - 16 GB - Space Gray
Apple iPod Nano (5th Generation) - 16 GB - Black
Apple iPod Nano (2nd Generation) - 4 GB - Green
.....
这样做与你的第二个查询。再一次,信贷去马库斯发现在您的XPath表达式中的两个错误。试着更加小心地写出这些表达式!特别是clsass
而不是class
应该很容易捕捉到,如果你看看你的代码两次。
=IMPORTXML("http://www.google.com/search?tbm=shop&q=ipod+nano&gws_rd=ssl", "//h3[@class='r']")
结果:
Apple iPod Nano (7th Generation) - 16 GB - Slate
Apple iPod Nano (6th Generation) - 8 GB - Graphite
Apple iPod Nano (3rd Generation) - 4 GB - Silver
Apple iPod Nano (4th Generation) - 8 GB - Pink
Apple iPod Nano (PRODUCT) RED (7th Generation) - 16 GB - Red
Apple iPod Nano (2nd Generation) - 4 GB - Silver
Apple iPod Nano (5th Generation) - 8 GB - Black
Apple iPod Nano (4th Generation) - 8 GB - Silver
Apple iPod Nano (7th Generation) - 16 GB - Space Gray
Apple iPod Nano (5th Generation) - 16 GB - Black
Apple iPod Nano (2nd Generation) - 4 GB - Green
Apple iPod Nano (3rd Generation) - 8 GB - Pink
Apple iPod Nano (PRODUCT) RED Special Edition (2nd Generation) - 4 ...
Apple iPod Nano (1st Generation) - 2 GB - White
Apple iPod nano (PRODUCT) RED Special Edition (6th Generation) - 8 ...
Apple iPod Nano (PRODUCT) RED Special Edition (3rd Generation) - 8 ...
Apple iPod Nano (PRODUCT) RED Special Edition (5th Generation) - 8 ...
Engraved Apple iPod Nano 16GB - 8th Gen
Apple 16GB iPod nano (Blue) Brand new
Apple iPod Nano (3rd Generation) - 8 GB - Green
两个思路:1)首先尝试一个正常的HTTP地址,因为HTTPS通常需要特殊处理或设置的选项。 b)第二个XPath表达式包含两个错误。试试'// h3 [@ class ='r']'。 – 2014-10-20 09:36:39
是的,它的工作。谢谢@MarcusRickert – Diffy 2014-10-21 11:50:53