Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- import json
- response = requests.get('https://www.bilbasen.dk/brugt/bil/mercedes/b200-d/20-aut-5d/5973808')
- if response.status_code == 200:
- soup = BeautifulSoup(response.text, 'html.parser')
- data = soup.find_all('script')[-1].text.strip().replace('var _props = ', '').replace(';', '')
- jsonData = json.loads(data)['listing']['media']['images']
- for d in jsonData:
- print(d['url'])
- else:
- print(f'Error fetching data from the website')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement