<td class="main1">
<br>
<img width="519" height="768" alt="2011 New Year styles, in better quality!" src="http://www.causewaymall.com/shop/images/J-1045.5.jpg">
<br>
<img width="500" height="752" alt="2011 New Year styles, in better quality!" src="http://www.causewaymall.com/shop/images/T-3378.jpg">
</td>
如何使用nodejs获取url图像的代码?例如: 这是我的代码:
var jsdom = require('jsdom');
var url = 'http://www.causewaymall.com/shop/-i-163.html';
jsdom.env(url,
[
'http://code.jquery.com/jquery-1.5.min.js'
],
function(errors, window) {
console.log("Url Image : => " + window.$(".main1 img").attr("src"));
});
请告诉我先生。
答案 0 :(得分:0)
如果你的html看起来像这样:
<table>
<tr>
<td class="main1">
<br>
<img width="519" height="768" alt="2011 New Year styles, in better quality!" src="http://hmm.jpg">
<br>
<img width="500" height="752" alt="2011 New Year styles, in better quality!" src="http://hmm2.jpg">
</td>
</tr>
</table>
你应该能够使用:
提取img srcwindow.$('.main1').find('img').attr('src');