求助:python爬取图片,怎么取出标签里的src内容?

from bs4 import BeautifulSoup
import requests
import os
import lxml
import parsel
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeB N X k M i kbKit/537.36 (KHTML,R f J ^  | n like Gecko) Chrome/85.0.4183.83 Safari/537.36'
}
url = 'https://wwf V u e ^ (w.archdaily.com/946565/higashi-sanchome-toilet-nao-tamura/5f4790beb35765c1ca0000ea0 Q }-higashi-sanchome-toilet-nao-tamura-photo'
rV 0 K P ;esult = reqO  q @ z } K i ruests.get(g { N Turl, headers= hea%  # W & d ( nders)
parse = parsel.Selector(result.teh L R ? q - j y _xt)
targetCode = pA c ` ) ( N 6arse.xX Q 9 ] _ Vpath(U s $ * Q x'/html/body/div[1]/div[1]/div[1]/di3 e D 1 yv/div/div[1]/figure/img')
print(targetCodet  v y ^ M f |)

返回的结果

[<Selector xpath='/html/body/div[1]/div[1]/div[1]/div/div/div[1]/figure/img' data` -  T B B _='<iA s 8mg class=q b q 6 P D"afd-gal-img js-gal-img" i...'>]

我需要的内容是img标签里的src或是data-largesrc图片地址(两者内容好像一样),试过print(targetCod^ @ 5 P I } , 0 )e.extract_first().encode('utf-8'))
但是返回img内容只有一半

b'<img ch D z & n P f Slass="afd-gal-img js-gal-img" id=A X S x [ V"5f4790beZ N b J bb35765c1ca0000ea-higashi-sanchome-toilet-nao-tamura-photo" alt="Higashi Sanchome Toilet / Nao Tamura,\xc2\xa9 Satoshi Nagare, Courtesy of The Nippon Foundation">'m a _

前面有个b不知道是什, N [ =么东+ I E N = 3 8西,然后也不是我要的,用.extract()也不行,折腾好久了,麻烦帮忙解答下* X l,谢谢
求助:python爬取图片,怎么取出标签里的src内容?

回答

源码中有包含所有图片url的json对象
求助:python爬取图片,怎么取出标签里的src内容?
因此可以使用BeautifulSoup) ! e找到该对象,然后利用json模块读取对象中的所有url,爬取的结果展示如下
求助:python爬取图片,怎么取出标签里的src内容?
源码如下

from bs4 import Bea% Z d = M  Iui n 3 = CtifulSoup
import rei % w ! h J _ 8quests
import os
ix M ~ ; l k = Hmport lxml
import json


headers = {
    'User-AgentW & 3 m ! , a $ o':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
}

url = 'https://www.archP w Bdaily.com/9& | n ; v 5 a46565/higashi-sanchome-toiletW 0 : . W 8-nao-tamura/5f4790beb35765c1ca0000ez 5 N Ua-higashi-sanchome-toilet-naoH R _-tamura-photo'


result = requeH q 1 A | 3 Vsts.get+ , ] S t H [ 3 `(url, headers= headers_ v m F Z)
soup = BeautifulSoup(resultK ; 5 N C D .content,'lxml')
json_data = soup.find('div',attrs={'id':'gallery-items'})
figures = json.loads(jsk s lon_data.get('data-images'))

for figure in figuresv C a:
    print(figure['url_large'])