R
R
ReDeNDeR2021-02-28 21:01:21
Python
ReDeNDeR, 2021-02-28 21:01:21

The parser does not work for the customer, what should I do?

Good afternoon, I made a link parser for google maps, but it does not work for the customer. In the video, you can roughly understand how it should work - it parses links from the left block. This video was sent by the customer, I have parse links and are inserted into a text document, but the customer does not have it. Thank you so much for your help

Program code:

from selenium import webdriver
from time import sleep
from selenium.webdriver.chrome.options import Options

driver = webdriver.Chrome()

driver.get('https://www.google.ru/maps/')

Search = input('Search: ')

driver.find_element_by_xpath("//input[@id='searchboxinput']").send_keys(Search + '\n')
sleep(5)

while True:
    try:
        driver.find_element_by_xpath("//div[@class='section-result-text-content']").click()
        break
    except:
        sleep(0.1)

num = -1
number = 1
list = []
sleep(5)
while True:
    #print(driver.find_element_by_xpath("//div[@class='section-layout section-layout-root'][1]/div/div/div/div/div/div").get_attribute('class'))
    #driver.find_element_by_xpath("//div[@class='section-layout section-layout-root'][1]/div/div/div/div/div/div").click()
    while True:
        try:
            a = driver.find_elements_by_xpath("//div[@class='section-carousel-item-container'][1]/div[" + str(number) + "]")
            break
        except:
            sleep(0.1)
            
    number = 1 + number
    for i in a:
        num = num + 1
        list.append(i.get_attribute('aria-label'))
    
    click = 0
    while True:
        try:
            #print(driver.find_element_by_xpath("//div[@aria-label='" + str(list[num]) + "'][1]/div[2]"))
            driver.find_element_by_xpath("//div[@aria-label='" + str(list[num]) + "'][1]/div[2]").click()
    #driver.find_element_by_xpath("//div[@class='rLwmCGCu6mP__image-container']").click()
            break
        except:
            sleep(0.1)
            click = click + 1

    sleep(3)    
    links = 0
    file = open('Map_links.txt', 'a')
    while links != 1:
        try:
            
            file.write(driver.find_element_by_xpath("//button[@data-tooltip='Open website']").get_attribute('aria-label') + '\n')
            print(driver.find_element_by_xpath("//button[@data-tooltip='Open website']").get_attribute('aria-label'))
            break
        except:
            sleep(1)
            links = 1 +links

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
dEN__5, 2021-02-28
@dEN__5

why not use
driver = webdriver.Chrome()
this instead

river = webdriver.Chrome(chrome_options=options, executable_path=ChromeDriverManager().install())

also add import
from webdriver_manager.chrome import ChromeDriverManager

A
Alexander, 2021-02-28
@sanya84

Maybe the driver is not compatible with the browser?
Your driver version

chromedriver_version
does not match the customer's browser version.

A
Antonio Solo, 2021-03-01
@solotony

see everything that differs on the customer's machine and on yours. there may be 100500 reasons. especially considering that selenium uses different configs for you and the customer. For example, different regional settings, you are not logged in, etc.

O
organica, 2021-03-02
@organica

I had such crap because of the wrong version of Chrome / Driver. Ask your customer for the version of chrome or let him run the script through the console, there you will immediately see this error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question