python - Python网页抓取图片路径,但标签和值不在同一行,无法得到结果
问题描述
我正在尝试抓取图片,但最后我发现标签和值不在同一行,所以当我使用 xpath 获取值但失败时。这是我的代码:
import requests,random,re,os
from fake_useragent import UserAgent
from lxml import etree
url='https://www.webtoon.xyz/read/what-does-the-fox-say/chapter-133/'
header ={'user_agent':random.choice(UserAgent().chrome)}
req=requests.get(url).content.decode('utf-8')
html=etree.HTML(req)
img_list=html.xpath("//div[@class='reading-content']/div[@class='page-break no-gaps']//@src")
print(img_list)
是不是标签src
和值不在同一行所以导致空结果?我怎样才能得到路径?
解决方案
推荐阅读
- jquery - 如何将数据从rails中的控制器传递给模态?
- php - 控制器类存在但未找到
- aws-lambda - 如何将 Lambda Authorizer 上下文参数传递给后端 API
- bash - 更改 bash 中的 crtime
- flutter - 如何在颤动中增加 SingleChildScrollView 的大小?
- linux - 如何将 gcloud 计算实例列表输出格式化为 excel 格式
- javascript - 使用carrierwave在Rails中上传带有trix的图像
- transform - 有没有办法防止四元数行为不端?
- python - 使用 Python 过滤复杂的 JSON 数组
- java - 每当我单击此 SetupActivity 中的保存按钮时,我的应用程序就会崩溃。每当我要在 Firebase 数据库中写入时,我的应用程序就会崩溃