我试图使用YQL获取imdb图像的src。我不确定XPath应该是什么 - 它是Firebug给你的XPath吗?你能告诉我为什么这会失败,什么是正确的XPath?谢谢试图从使用YQL xpath的页面获取图像
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<script>
$.getJSON(
'http://query.yahooapis.com/v1/public/yql?callback=?',
{
q: 'select * from html where url="http://www.imdb.com/find?q=back+to+the+future&s=all" and xpath="/html/body/div[1]/div/div[4]/div[3]/div[1]/div/div[2]/table/tbody/tr[1]/td[1]/a/img"',
format: 'json'
},
function(data) {
console.log(data.query.results)
}
);
</script>
<div id='yqlresult'>
</div>
</body>
</html>
OK,加上安装FirePath插件,并得到了这个XPath,但仍然没有喜悦:(.//*[@id= 'main']/div/div [2]/table/tbody/tr [1]/td [1]/a/img – SIndhu