here is the link "https://www.blocket.se/annons/stockholm/samsung_note10__i_nyskick_med_kvitto/92119857"
and i want to extract an image of phone
"<div style="left:0%;background-image:url(https://i.blocketcdn.se/pictures/2835058804.jpg?type=original);width:100%;height:100%;background-size:contain;background-position:50% 50%;background-repeat:no-repeat;position:absolute"></div>"
when i search with find_all, i get background image and not the one i want ( phone ), or None
Anyone with the idea how to extract just an phone image
You can extract the image url from <meta ...>
tag:
import requests
from bs4 import BeautifulSoup
url = 'https://www.blocket.se/annons/stockholm/samsung_note10__i_nyskick_med_kvitto/92119857'
soup = BeautifulSoup(requests.get(url).content, 'lxml')
img_url = soup.select_one('[property="og:image"]')['content']
img_url_original = img_url.split('?')[0] + '?type=original'
print(img_url_original)
Prints:
https://i.blocketcdn.se/pictures/2835058804.jpg?type=original
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.