如何在xpath中获取src链接

2024-09-27 01:30:18 发布

您现在位置:Python中文网/ 问答频道 /正文

这是html

<div class="c" id="M_Fp01sdJgm">
    <div>
        <a class="nk" href="https://weibo.cn/thebs">figre</a>
            <img src="https://h5.sinaimg.cn/upload/2016/05/26/319/5338.gif" alt="V"/>
            <img src="https://h5.sinaimg.cn/upload/2016/05/26/319/donate_btn_s.png" alt="M"/>
      <span class="ctt">
                    ":"resampling
                    <span class="kt">resampling</span>
                    ":Cleantech entrepreneurs are splicing genes in the search for greener fuels
                ​</span>&nbsp;
                [<a href="https://weibo.cn/mblog/picAll/Fp01sdJgm?rl=2">2 pieces of the package</a>
                </div>
    <div>
        <a href="https://weibo.cn/mblog/pic/Fp01sdJgm?rl=1">
          <img src="http://wx1.sinaimg.cn/wap180/3ed2e6e8gy1fk7hohl2i5j219s0ps4qp.jpg" alt="images" class="ib" />
        </a>&nbsp;
        <a href="https://weibo.cn/mblog/oripic?id=Fp01sdJgm&amp;u=3ed2e6e8gy1fk7hohl2i5j219s0ps4qp">image</a>&nbsp;
        <a href="https://weibo.cn/attitude/Fp01sdJgm/add?uid=5757914684&amp;rl=1&amp;st=7b15a6">praise[28094]</a>&nbsp;
        <a href="https://weibo.cn/repost/Fp01sdJgm?uid=1054009064&amp;rl=1">transmit[1164]</a>&nbsp;
        <a href="https://weibo.cn/comment/Fp01sdJgm?uid=1054009064&amp;rl=1#cmtfrm" class="cc">comment[4097]</a>&nbsp;<a href="https://weibo.cn/fav/addFav/Fp01sdJgm?rl=1&amp;st=7b15a6">save</a>
        "<!---->&nbsp;"
        <span class="ct">10月05日 20:08&nbsp;from iPhone 7 Plus

我试着写下以下,其他领域都有得到了。但是“img”为空

^{pr2}$

我该怎么写“img”? 然后我可以通过zip()处理它们?因为我要保存mysql


Tags: httpsdivsrcimgcnaltclassrl

热门问题