Как вытащить картинки из кода в переменной?

art22

Client
Регистрация
24.06.2016
Сообщения
484
Благодарностей
69
Баллы
28
Добрый день. Спарсил определённый кусок кода, в нем есть картинки как мне сохранить их в списке чтобы потом их скачать. помню была какая то формула не смог найти

cdn.stamped.io/tr:h-800,/uploads/photos/ -- ссылка на картинку в данном коде 3 таких

C#:
            <h3 class="stamped-review-header-title">Looks so natural</h3>            
            <p class="stamped-review-content-body">I love love this piece, right out of the box. I love that I can part it on the side or in the middle. It looks so real and I get so many compliments. I got it in Shaded biscuit and it looks beautiful.
</p>            
            <div class="stamped-review-image">                
                <a href="//cdn.stamped.io/tr:h-800,/uploads/photos/11643_9279256970_8ed6ec8b_fcd6_4fae_b6e4_5262e461b1e8.jpg?" target="_blank" class="stamped-review-link-photo" onclick="StampedFn.openUGCPhoto(100156880,9279256970, 0, true);return false;" onkeyup="StampedFn.openUGCPhoto(100156880,9279256970, 0, true);return false;" ref="nofollow"><img class="stamped-lazyload stamped-lazyload-loaded" data-src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_8ed6ec8b_fcd6_4fae_b6e4_5262e461b1e8.jpg?" height="130" alt="Wigs.com – The Wig Experts™ Show Stopper | HF Synthetic Lace Front Wig (Mono Top) Review" style="margin-right:10px; height:130px;" src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_8ed6ec8b_fcd6_4fae_b6e4_5262e461b1e8.jpg?" data-was-processed="true"></a><a href="//cdn.stamped.io/tr:h-800,/uploads/photos/11643_9279256970_3d450e88_4974_4b01_9b59_b211a043e202.jpg?" target="_blank" class="stamped-review-link-photo" onclick="StampedFn.openUGCPhoto(100156880,9279256970, 1, true);return false;" onkeyup="StampedFn.openUGCPhoto(100156880,9279256970, 1, true);return false;" ref="nofollow"><img class="stamped-lazyload stamped-lazyload-loaded" data-src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_3d450e88_4974_4b01_9b59_b211a043e202.jpg?" height="130" alt="Wigs.com – The Wig Experts™ Show Stopper | HF Synthetic Lace Front Wig (Mono Top) Review" style="margin-right:10px; height:130px;" src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_3d450e88_4974_4b01_9b59_b211a043e202.jpg?" data-was-processed="true"></a><a href="//cdn.stamped.io/tr:h-800,/uploads/photos/11643_9279256970_daf214ed_14f7_460a_876b_a83b2320e5aa.jpg?" target="_blank" class="stamped-review-link-photo" onclick="StampedFn.openUGCPhoto(100156880,9279256970, 2, true);return false;" onkeyup="StampedFn.openUGCPhoto(100156880,9279256970, 2, true);return false;" ref="nofollow"><img class="stamped-lazyload stamped-lazyload-loaded" data-src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_daf214ed_14f7_460a_876b_a83b2320e5aa.jpg?" height="130" alt="Wigs.com – The Wig Experts™ Show Stopper | HF Synthetic Lace Front Wig (Mono Top) Review" style="margin-right:10px; height:130px;" src="//cdn.stamped.io/tr:h-180,/uploads/photos/11643_9279256970_daf214ed_14f7_460a_876b_a83b2320e5aa.jpg?" data-was-processed="true"></a>            
            </div>            
            <div class="stamped-review-product"><a href="https://stamped.io/go/d3xXaWRnZXRNYWlufDExNjQzfHJ8MTAwMTU2ODgw0" rel="nofollow" target="_top">Show Stopper | HF Synthetic Lace Front Wig (Mono Top)</a></div>            
            <div class="stamped-review-variant" style="display:none;">RL19/23SS</div>            
            <div class="stamped-review-footer">                
                <div class="stamped-review-share">
<div class="stamped-share-wrapper">  
    <span class="stamped-share-icon" aria-label="Share" role="button" tabindex="0" rel="nofollow noopener"><i class="stamped-fa stamped-fa-share-alt"></i> Share</span>  
    <span class="stamped-share-links" style=""> &nbsp; | &nbsp;&nbsp;<a href="https://www.facebook.com/dialog/share?app_id=222664514734026&amp;display=popup&amp;href=https%3a%2f%2fwww.wigs.com%2fa%2freview%2ffacebookpost%3freviewId%3d100156880&amp;redirect_uri=https://stamped.io/shares?review_id=100156880" target="_blank" rel="nofollow noopener" aria-label="Share review on Facebook">Facebook</a> &nbsp;•&nbsp; <a href="https://twitter.com/intent/tweet?text=I%20love%20love%20this%20piece%2C%20right%20out%20of%20the%20box.%20I%20love%20that%20I%20can%20part%20it%20on%20the%20side%20or%20in%20the%20middle.%20It%20looks%20so%20real%20and%20I%20get%20so%20many%20com&amp;url=https%3a%2f%2fwww.wigs.com%2fa%2freview%2ftwittercard%3freviewId%3d100156880" target="_blank" rel="nofollow noopener" aria-label="Share review on Twitter">Twitter</a></span>
</div></div>                
                <div class="stamped-review-vote"><div class="stamped-rating-holder">Was this helpful? <a class="stamped-thumbs-up" data-rating="1" data-review-id="100156880" tabindex="0" aria-label="Rate review as helpful" role="button"><i class="stamped-fa stamped-fa-thumbs-up">&nbsp;6</i></a><span>&nbsp;&nbsp;&nbsp;</span><a class="stamped-thumbs-down" data-rating="-1" data-review-id="100156880" tabindex="0" aria-label="Rate review as not helpful" role="button"><i class="stamped-fa stamped-fa-thumbs-down">&nbsp;0</i></a></div>
</div>            
            </div>
 
Последнее редактирование:

impul5e

Client
Регистрация
15.08.2017
Сообщения
202
Благодарностей
40
Баллы
28
Вот такой регуляркой:
(?<=<a\ href="//).*?\.jpg
 
  • Спасибо
Реакции: art22

Michaelson6565

Новичок
Регистрация
19.04.2023
Сообщения
5
Благодарностей
0
Баллы
1
const htmlCode = "<img
src='image.jpg'><img
src='image2.png'>";
const regex = /<img.*?src=['"]
(.*?)['"]/g;
let match; while ((match = regex.exec(htmlCode)) !== null)
{ console.log(match[1]); }
Этот код найдет все теги <img> с атрибутом src и выведет значения этого атрибута (URL картинок) в консоль.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)