V
V
vodniks2021-09-30 01:20:21
Python
vodniks, 2021-09-30 01:20:21

How to monitor goods on OZON.ru?

Due to the lack of consoles on the market, there was a desire to create their own Ozone monitor for the presence of PS5 and XBOX SX. As a result of 3-4 hours of googling, it turned out to write such a monitor:

from selenium import webdriver
import csv
from datetime import datetime
 
def chek(browser, console):
    a = 1
    all_span = browser.find_elements_by_tag_name("h2")
    all_span = [i.text for i in all_span]
    is_availiable = ""
    if "Этот товар закончился" in all_span:
       is_available = False
    else:
        all_span = browser.find_elements_by_tag_name("div")
        #all_span = [i.text for i in all_span]      
        if "Добавить в корзину" in all_span:
            is_available = True
            with open("ps5.csv", "a") as csvfile:
               write = csv.writer(csvfile)
               date = datetime.now()
               write.writerow([date, is_available, console])
        else: 
           browser.close()
           is_available = False
           a = 0
           return a
    
 
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
#options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0')
 
browser = webdriver.Chrome("C:\\WebDriver\\bin\\chromedriver.exe")
browser.set_page_load_timeout(60)
while True:
    browser.get("https://www.ozon.ru/product/igrovaya-konsol-playstation-5-digital-edition-belyy-178715781/?sh=gY51skAT")
    a = chek(browser, 'ps')
    if a == 0:
         browser = webdriver.Chrome("C:\\WebDriver\\bin\\chromedriver.exe")
    browser.get("https://www.ozon.ru/product/igrovaya-konsol-microsoft-xbox-series-x-chernyy-173667655/?sh=fkCugO8e")
    a = chek(browser, "xbox")
    if a == 0:
         browser = webdriver.Chrome("C:\\WebDriver\\bin\\chromedriver.exe")


Everything works on the principle of "refresh the page until it appears." The question arose: how to bypass the captcha when the page is refreshed multiple times? (For now, I just close the browser and open it again until the captcha disappears)

What other monitoring tools are there? Where can you get information? What else can be used?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-09-30
@ForestAndGarden

What other monitoring tools are available?

Google Sheets, for example, with its IMPORTXML() and IMPORTHTML() .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question