Scraping Lazada Thailand with BeautifulSoup can also involve navigating through multiple pages to scrape all products. Pagination is often hidden in JavaScript, but requests can fetch each page’s HTML for parsing. In this example, we fetch the product listings and parse the title, price, and ratings (if available). If you want to go deeper, you could explore the product pages by following links to each individual product.
import requests
from bs4 import BeautifulSoup
url = 'https://www.lazada.co.th/catalog/?q=tv'
headers = {'User-Agent': 'Mozilla/5.0'}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, 'html.parser')
# Get all products listed on the first page
products = soup.find_all('div', class_='c2prKC')
for product in products:
title = product.find('div', {'class': 'c16H9d'}).text.strip()
price = product.find('span', {'class': 'c13VH6'}).text.strip()
print(f'Title: {title}, Price: {price}')