You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用BeautifulSoup获取Booklooker页面高清图片链接的问题求助

问题分析

你当前代码的核心问题是定位错了元素:

  • 你抓取的是preview hasXXL类的<a>标签,这个标签的href是图片预览跳转页的链接,并非高清图直链。
  • 高清图的真实直链存储在页面内图片元素的data-xxl属性中。
修正后的代码
from bs4 import BeautifulSoup
import requests

url = "https://www.booklooker.de/B%C3%BCcher/Donna-W-Cross+Die-P%C3%A4pstin/id/A02A8f9001ZZl"
page = requests.get(url)
souped = BeautifulSoup(page.content, "html.parser")

# 提取带有data-xxl属性的图片链接(高清图直链)
for img in souped.find_all("img", attrs={"data-xxl": True}):
    print(img["data-xxl"])
备选实现方式

如果想基于你原本定位的preview hasXXL标签来提取,可通过其内部的<img>元素获取data-xxl属性:

from bs4 import BeautifulSoup
import requests

url = "https://www.booklooker.de/B%C3%BCcher/Donna-W-Cross+Die-P%C3%A4pstin/id/A02A8f9001ZZl"
page = requests.get(url)
souped = BeautifulSoup(page.content, "html.parser")

for preview_link in souped.find_all(class_="preview hasXXL"):
    target_img = preview_link.find("img")
    if target_img and "data-xxl" in target_img.attrs:
        print(target_img["data-xxl"])

内容的提问来源于stack exchange,提问作者Benedikt Faude

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 08:36:22