R
R
rew233322021-07-03 17:37:50
Python
rew23332, 2021-07-03 17:37:50

How to parse parimatch python3?

Hello, please help! I can’t properly parse the top column in parimach. I tried the xpath parser for a day, then it gives an error (I suppose the html changes dynamically) I need to pull out the result of n1 and n2, name and time!

Here is my code, I will be grateful to anyone who modifies it and tells you how not to do it

from selenium import webdriver
import selenium
import time
 
driver = webdriver.Chrome()
 
driver.get('https://parimatch.com/ru/table-tennis')
time.sleep(4)
 
block = driver.find_elements_by_class_name('_2c98cYcZ15eCL3kXBibIh_')[:1]
for item in block:
    name = item.find_element_by_class_name('_26B_f8qfrQUqtdUjGVw3dk').text
    time = item.find_element_by_class_name('_1LmvJKRD8MAsF3wKlXcsgF').text[9:]
    p1 = item.find_element_by_class_name('_3Sa1tkZVXvesvtPRE_cUEV').text
    p2w = item.find_elements_by_class_name('_3Sa1tkZVXvesvtPRE_cUEV')[1:]
    for i in p2w:
        p2 = i.text
 
        info = []
        if float(p1) > 1.83 and float(p1) < 1.90:
            if float(p2) > 1.83 and float(p2) < 1.90:
                result = {"times": time, "name": name, "p1": p1, "p2": p2, }
                info.append(result)
 
        print(info)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question