这是html代码,我想从中选择所有src,我可以从中选择所有src
<div class="thumbnails-wrapper" style="display: inline-block; visibility: visible;">
<div class="thumbnails" data-expand-target="thumbnails">
<span class="details-trailer">
<span class="video-image-wrapper">
<span class="preview-overlay-container" data-video-url="https://www.youtube.com/embed/lXaGPCSqlsM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1&authuser=0" data-docid="com.gameloft.android.ANMP.GloftAGHM">
</span>
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail " alt=" Asphalt Nitro- screenshot thumbnail " src="//lh3.googleusercontent.com/x7dX056Uo1zlIsTx1rN2NO19g3ETS2J-8A6rmrypc-k_VPdMY5hnoFSVS-MENXfUfqBL=h310" data-expand-to="full-screenshot-0">
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail " alt=" Asphalt Nitro- screenshot thumbnail " src="//lh3.googleusercontent.com/iXwUtiXyragrVn6BeQq2OFFeNR0z1JJVaNELuQscWlizBiwn-dGO1Jb9T8UO29NW2DI=h310" data-expand-to="full-screenshot-1">
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail " alt=" Asphalt Nitro- screenshot thumbnail " src="//lh3.googleusercontent.com/ueH3VEOiN414QwlDUtoRE4-xyV1ucHF3puKRXHtMeJFrkqrlAeC_OcVHV3JKGYiKC8A=h310" data-expand-to="full-screenshot-2">
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail " alt=" Asphalt Nitro- screenshot thumbnail " src="//lh3.googleusercontent.com/2VIXmIvny4xxbDVALMUumX4hdIM38P9OHp0PhT0ktFT7CyNcEX22QjpSsI6hQaWRYxM=h310" data-expand-to="full-screenshot-3">
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail " alt=" Asphalt Nitro- screenshot thumbnail " src="//lh3.googleusercontent.com/fxSqT5CXu1TmSS2MMjmPXnEXbzIMaBr2mlA3SdA1lRI3rr4IMwPUBHAvS4_UE1uXZN73=h310" data-expand-to="full-screenshot-4">
<img class="screenshot clickable" tabindex="0" itemprop="screenshot" title=" Asphalt Nitro- screenshot thumbnail
最佳答案
使用BeautifulSoup
soup = BeautifulSoup(html)
for i in soup.select('.thumbnails-wrapper img'):
print i['src']
或
print [i.get('src', None) for i in soup.select('.thumbnails-wrapper img')]