0

I am trying to scrape data table for those 3 stages in the picture(stages marked in red). enter image description here

unfortunately, the code I've written is getting first table only for some reason. I have already tired other way round by getting Xpath for those individual tables but that doesn't quite work as it gave similar problem there too. Thanks in advance for your help.

website link: https://mcchip-dkr.com/en/chiptuning-database?fid=3222&view=carselector#0

for i in range(0, len(stage_button)):
    print("pointer is ", pointer)
    print("CLick on next stage\n")
    time.sleep(2)
    stage_button[pointer].click()
    time.sleep(5)
    table_li_tag = driver.find_element(By.CSS_SELECTOR, "li.uk-active")

    table_pointer = table_li_tag.find_element(By.XPATH, "//table")
    print(table_pointer.get_attribute("outerHTML"))
    pointer = pointer + 1
    if pointer > len(stage_button):
        break

1 Answer 1

1

I have used Selenium and tried this way. It fetched me output:

driver.get("https://mcchip-dkr.com/en/chiptuning-database?fid=3222&view=carselector#0")
time.sleep(5)
for i in range(3):
    driver.find_element(By.XPATH, f"//div[@id='mcw_datasheet']//li[@data-index={i}]").click()
    time.sleep(2)
    stage = driver.find_element(By.XPATH, f"(//ul[@id='#switcher1']//table){str([i+1])}").text
    print(stage)
    print("\n")

The only element left out is (I am not sure what the metric is): 3.999,00 € for each stage. I hope you can figure it out.

Here is the ouput:

Stock Optimized Diference
750 hp / 551 kW 780 hp / 574 kW 30 hp / 22 kW
690 Nm 725 Nm 35 Nm
350 Km/h 353 Km/h 3 Km/h


Stock Optimized Diference
750 hp / 551 kW 790 hp / 581 kW 40 hp / 29 kW
690 Nm 735 Nm 45 Nm


Stock Optimized Diference
750 hp / 551 kW 800 hp / 588 kW 50 hp / 37 kW
690 Nm 740 Nm 50 Nm



Process finished with exit code 0

I have used just prints, but you may arrange to have the table stored in list and/or in pandas table if you like to do so.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.