I am trying to scrape a website with multiple brackets. My plan is to have 3 varbiales (oem, model, leadtime) to generate the desired output. However, I cannot figure out how to scrape this webpage in 3 variables. Given I am new to python and beautfulsoup, I highly appreciate your feedback. Thanks in advance!
Desired output with 3 varibles and the command: print(oem, model, leadtime)
Audi, A1 Sportback, 27 weeks
Audi, A3 Sportback, 27 weeks
...
Volvo, XC90, 27 weeks
Error of code as of now:
AttributeError: 'NavigableString' object has no attribute 'select'
Code as of now:
from bs4 import BeautifulSoup
import requests
response = requests.get("https://www.carwow.co.uk/new-car-delivery-times#gref").text
soup = BeautifulSoup(response, 'html.parser')
for tbody in soup.select('tbody'):
for tr in tbody:
oem = tr.select('td > a')[0].get('href').split('/')[3].capitalize()
model = tr.select('td > a')[0].get('href').split('/')[4].capitalize()
lead_time = tr.select('td')[1].getText(strip=True)
print(oem, model, lead_time)