I'm just learning web scraping & want to output the result of this website to a csv file https://www.avbuyer.com/aircraft/private-jets
but am struggling with parsing the next pages
here is my code (with help of Amen Aziz) which only gives me the 1st page
I'm using Chrome so not sure if it makes any difference
I'm running Python 3.8.12
Thank you in advance
import requests
from bs4 import BeautifulSoup
import pandas as pd
headers= {'User-Agent': 'Mozilla/5.0'}
response = requests.get('https://www.avbuyer.com/aircraft/private-jets')
soup = BeautifulSoup(response.content, 'html.parser')
postings = soup.find_all('div', class_ = 'listing-item premium')
temp=[]
for post in postings:link = post.find('a', class_ = 'more-info').get('href')link_full = 'https://www.avbuyer.com'+ linkplane = post.find('h2', class_ = 'item-title').textprice = post.find('div', class_ = 'price').textlocation = post.find('div', class_ = 'list-item-location').textdesc = post.find('div', class_ = 'list-item-para').texttry:tag = post.find('div', class_ = 'list-viewing-date').textexcept:tag = 'N/A'updated = post.find('div', class_ = 'list-update').textt=post.find_all('div',class_='list-other-dtl')for i in t:data=[tup.text for tup in i.find_all('li')]years=data[0]s=data[1]total_time=data[2]temp.append([plane,price,location,years,s,total_time,desc,tag,updated,link_full])df=pd.DataFrame(temp,columns=["plane","price","location","Year","S/N","Totaltime","Description","Tag","Last Updated","link"])next_page = soup.find('a', {'rel':'next'}).get('href')
next_page_full = 'https://www.avbuyer.com'+next_page
next_page_fullurl = next_page_full
page = requests.get(url)
soup = BeautifulSoup(page.text, 'lxml') df.to_csv('/Users/xxx/avbuyer.csv')