python - Python:我如何得到背景图像 url 值
问题描述
目前我正在使用下面的代码来获取页面上的所有 img 标签。我可以以某种方式访问 background-img url 值吗
import random
import urllib.request
import requests
from bs4 import BeautifulSoup
#1. Reading pages
source = requests.get("https://www.dummie-website/photos_all").text
soup = BeautifulSoup(source,'lxml')
enter code here
#2. Getting every 'src' value from all img tags
match = [x['src'] for x in soup.findAll('img', {'class': ''})]
for i in match:
print(i)
解决方案
推荐阅读
- python-3.x - 加入多索引数据框和单索引数据框
- c# - 在 .NET Core Angular 中使用 IP 摄像头广播流
- numpy - Numpy:一次索引 2 个维度
- kubernetes - 用于外部服务的 Istio Egress MTL
- laravel - composer global 需要 laravel/installer 卡在“更改当前目录”
- php - 将自己的类代码放在单独的文件中后,管理类不可用
- google-sheets - 在 Google 表格中按字母顺序排列/排序
- python - Straithforward if 语句得到 ValueError:Series 的真值不明确
- jenkins-groovy - Jenkins Spock 测试因 java.lang.NoSuchMethodError 失败:com.google.common.collect.Sets
- python - Groupby,移位和前向填充