Through web scraping, I get two lists, one is the name and the other is the price of a product. How can I enter these values in two columns at the same time so that the price of each product is in front of it?
import mysql.connector
import re
from bs4 import BeautifulSoup
import requests
list_esm=[]
list_gheymat=[]
cnx = mysql.connector.connect(user='root', password='',
host='127.0.0.1',
database='vorodi')
cursor = cnx.cursor()
user = str(input())
url =('https://divar.ir/s/tehran?q=')
search = requests.get(url + user)
search.text
soup = BeautifulSoup(search.text, 'html.parser')
esm = soup.find_all('div', attrs={'class':'kt-post-card__title'})
gheymat = soup.find_all('div', attrs={'class':'kt-post-card__top-description'})
for i in esm:
w = re.sub(r'\s+',' ',i.text).strip()
list_esm.append(w)
for i in gheymat:
q= (re.sub(r'^\s*',' ' ,i.text).strip())
list_gheymat.append(q)
query_1 = """INSERT INTO divar_2 (name,price) VALUES (%r,%r);""" %(tuple(list_esm),tuple(list_gheymat))
cursor.execute(query_1)
cnx.commit()
cnx.close()