....
$(window).load(function () {
const initialState = () => {
if (localStorage.getItem('products') !== null) {
document.getElementById("wishlist").innerHTML = localStorage.getItem('products');
}}
;
const listener = function() {
let check = document.getElementById('button-delete-card');
if (check !== null) {
addEventListener("click", removeItem);
}
};
listener()
initialState();
})
....
from selenium.webdriver import Chrome
from selenium.webdriver.common.keys import Keys
from time import sleep
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium import webdriver
import csv
import json
chrome_options = Options()
#chrome_options.headless = True
driver1 = Service("C:\\Users\\*****\\JupiterScraping\\chromedriver.exe")
driver = webdriver.Chrome(options=chrome_options)
driver.set_window_size(1280, 1920)
Data = []
url = '.....'
driver.get(url)
closemodal = driver.find_element(By.CLASS_NAME, 'rb-modal-close').click()
with open('urllist.txt', encoding="utf-8") as file:
count = 0
lines = [line.strip() for line in file.readlines()]
for line in lines:
driver.get(line)
#Закрываем модальное окно
driver.execute_script("window.scrollTo(0, 1080)")
sleep(1)
productname = driver.find_element(By.CLASS_NAME, 'rb-pdp-sticky-bar__model').text
polorize = driver.find_element(By.CLASS_NAME, 'rb-pdp-subtitle').text
description = driver.find_element(By.CLASS_NAME, "wcs-half-top").text
modelclass = driver.find_element(By.CLASS_NAME, 'rb-pdp-editorial__modelcode').text
polorize = driver.find_element(By.CLASS_NAME, 'rb-pdp-subtitle').text
#Определяем параметры продукта
pi = driver.find_elements(By.CLASS_NAME, 'rb-pdp-editorial__info-title')
parametersinfo = [i.text for i in pi]
del parametersinfo[0:3] #Удаляем лишние параметры из списка
#Определяем значения параметров продукта
p = driver.find_elements(By.CLASS_NAME, 'rb-pdp-editorial__info-subtitle')
parameters = [i.text for i in p]
#Клик и разворачивание скрытого блока с размером
click = driver.find_element(By.CLASS_NAME, 'rb-pdp-size-picker').click()
s = driver.find_elements(By.CLASS_NAME, 'rb-pdp-size-panel__sizes')
size = [i.text for i in s]
parclear = dict(zip(parametersinfo, parameters))
Data ={'Product Name': productname,
'Polorize Status': polorize,
'Description': description,
'Model Code': modelclass,
'Product Link': url,
}
Data.update(parclear)
def write_csv(Data):
with open('Ray-Ban-Product-Data.csv', 'a', encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow((Data['Product Link'],
Data['Product Name'],
Data['Polorize Status'],
Data['Description'],
Data['Model Code'],
Data['SHAPE'],
Data['FRAME COLOR'],
Data['MATERIAL'],
Data['CLASS'],
Data['COLOR'],
Data['TREATMENT'],
Data['LENS HEIGHT'],
Data['BRIDGE WIDTH'],
Data['TEMPLE LENGTH']
))
count += 1
print(f'#{count}: {line} is done!')
sleep(4)
with open('Data.json', "a") as json_file:
json.dump(Data, json_file, indent=4)
write_csv(Data)
var burger = document.getElementById('.burger');
var menu = document.getElementById('.menu');
if (burger.checked = true);
document.body.addEventListener("click", function(event) {
if (event.target != ms)
burger.checked = false;
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '48' == event.detail.contactFormId ) {
document.getElementById("fancybox-close").click(); return true;
$('popup-thx').modal();
}, false );
}
});