I would like to get data from an e-commerce website. However, I can get products but no more than 24. The site is using page index query parameter. I am sending the query parameter but still, the script gets 24 products.
The code, result and the website --> Screenshots
Code:
import requests
import sqlite3
from bs4 import BeautifulSoup
db = sqlite3.connect('veritabani.sqlite')
cursor = db.cursor()
cursor.execute("CREATE TABLE products (id, product, price)")
url = 'https://www.trendyol.com/cep-telefonu-x-c103498'
html_text = requests.get(url,params={'q': 'pi:5'}).text
soup = BeautifulSoup(html_text, 'lxml')
print(soup.contents)
products = soup.find_all("div", {"class": "p-card-wrppr"})
for product in products:
product_id = product['data-id']
product_name = product.find("div", {"class": "prdct-desc-cntnr-ttl-w two-line-text"}).find("span",{"class": "prdct-desc-cntnr-name"})["title"]
price = product.find_all("div", {"class": "prc-box-sllng"})[0].text
cursor.execute("INSERT INTO products VALUES (?,?,?)", (product_id,product_name,price))
print(product_id,product_name,price)
db.commit()
db.close()
pi(page index?) you still get the first 25 results?