import requests
from bs4 import BeautifulSoup
import re
findImg = re.compile(r'data-ks-lazyload="(.*?)"')
def askurl():
head = {
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36'
}
url = 'https://detail.tmall.com/item.htm?id=556772183225&ali_refid=a3_430583_1006:1151055037:N:DY8nPNoQXxCaUzcW5xAY4EwR15x8pB0i:ad0101273a205b498baa557cde64cb9b&ali_trackid=1_ad0101273a205b498baa557cde64cb9b&spm=a230r.1.14.1'
request = requests.get(url=url,headers=head)
html = request.text
return html
def getData():
html = askurl()
soup = BeautifulSoup(html,'html.parser')
i = 1
for item in soup.find_all('div',class_="mui-wpimagetext-item unloaded"):
item = str(item)
img = re.findall(findImg,item)[0]
print(img)
getData()
大佬这是我的代码,我没有太看懂您的意思。我想找的是详情图片的链接,你要找到真正拿到数据的那条request,直接去拿数据,不一定要看html 这个要咋看呢,我无法通过审查元素找到我需要的标签,那么我的BeautifulSoup要怎么写呢 |