【问题标题】:How to get image url by cheerio?如何通过cheerio获取图片网址?
【发布时间】:2019-11-11 14:08:21
【问题描述】:
const retURL = a.find('.gallery-carousel').find('img').attr('src')
.map(function(){ 
    let image=  $(this).attr('src'); 
    console.log(image, 'nnnnknknkn')
 })
 const retURL = $('div.carousel').attr('img')
 const retURL = $('gallery-carousel__image-touchable').text()

【问题讨论】:

  • 您的问题找到解决方案了吗?
  • @JayakumarThangavel 一点也不
  • 能否请您也添加HTML代码
  • var imageurl = $('.gallery-carousel__image-touchable').find('img').attr('src');
  • var imageurl = $('.slide button').find('img').attr('src');

标签: node.js image cheerio


【解决方案1】:

var listItems = $(".gallery-carousel ul li");
listItems.each(function(idx, li) {
    let image=  $(li).find('img').attr('src'); 
    console.log(image);
    // and the rest of your code
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div class="gallery-carousel">
<ul>
<li class="slide selected">
<button><img src="https://i.stack.imgur.com/rC97H.png" alt="hello" /> </button>
</li>
<li class="slide">
<button><img src="https://i.stack.imgur.com/1.png" alt="hello" /> </button>
</li>
<li class="slide">
<button><img src="https://i.stack.imgur.com/2.png" alt="hello" /> </button>
</li>
</ul>
</div>

【讨论】:

  • 请检查一下
猜你喜欢
  • 2018-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多