Всем доброго дня
Сделал парсинг сайта
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import csv
import os
from threading import *
import requests
from concurrent.futures import ThreadPoolExecutor, wait
from time import time,sleep
URL = 'https://www.dns-shop.ru/catalog/17a8a01d16404e77/smartfony/'
HEDARS = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}
FILE = 'dns.csv'
direct= os.getcwd()
def get_himl(url):
chromedriver = direct + '/chromedriver'
options = webdriver.ChromeOptions()
browser = webdriver.Chrome(executable_path=chromedriver, chrome_options=options)
browser.get(url)
r = browser.page_source
sleep(1)
browser.quit()
return r
def seve_file(item,path):
with open(path, 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file, delimiter = ';')
writer.writerow(['беренд', 'модель', 'цена', 'акции'])
for items in item:
writer.writerow([items['brand'], items['title'], items['prise'], items['sale']])
def get_content(html):
soup = BeautifulSoup(html, 'html.parser')
items = soup.find_all(class_='catalog-product ui-button-widget')
for items in items:
prise = items.find('div', class_='product-buy__price')
if prise:
prise = prise.get_text()
prise = prise.replace('₽', ' ')
else:
prise = ''
s = items.find('div', class_='vobler')
if s:
s = s.get_text()
else:
s = ''
name = items.find('a', class_='catalog-product__name ui-link ui-link_black').get_text()
name = name.split()
start = 0
stop = 0
for i in range(len(name)):
if name[i] == 'Смартфон':
start = i
if name[i] == 'ГБ':
stop = i
name = name[start + 1:stop + 1]
name = ' '.join(name).lower()
brand = name.split()[0]
phone.append({
'brand': brand,
'title' : name,
'prise' : prise,
'sale' : s
})
return (phone)
def pars(num):
a = URL + '?p=' + str(num)
html = get_himl(a)
phone.extend(get_content(html))
seve_file(phone, FILE)
if __name__ == "__main__":
phone = []
with ThreadPoolExecutor() as executor:
for num in range(1, 3):
executor.submit(pars, num)
print('Все=)')
Но тут незадача
items = soup.find_all(class_='catalog-product ui-button-widget')
for items in items:
prise = items.find('div', class_='product-buy__price')
Результат нет данного тега при парсинге
однако если смотреть код страницы он есть
для примера
https://www.dns-shop.ru/search/?q=BQ+5047L+
<div class="product-buy__price">4 499 ₽</div>
смотрел полностью html который селениум возвращает там нет данного тега
Подскажите что не так?