Advertisement
kingbode

Untitled

Nov 23rd, 2023
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import json
  4.  
  5.  
  6. response = requests.get('https://www.bilbasen.dk/brugt/bil/mercedes/b200-d/20-aut-5d/5973808')
  7.  
  8. if response.status_code == 200:
  9.     soup = BeautifulSoup(response.text, 'html.parser')
  10.  
  11.     data = soup.find_all('script')[-1].text.strip().replace('var _props = ', '').replace(';', '')
  12.  
  13.     jsonData = json.loads(data)['listing']['media']['images']
  14.     for d in jsonData:
  15.         print(d['url'])
  16. else:
  17.     print(f'Error fetching data from the website')
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement