I am trying scrape data out of 'https://www.velocityap.com/product/3-0l-v6-supercharged-jaguar-land-rover-aj126-ecu-tuning/' website. For which, set of radio button options need to clicked to reveal price for the car part(price marked in red in picture below) which needs to scraped.
Code I've written to achieve that is as follows:
options_panel_4 = driver.find_elements(By.CSS_SELECTOR,'div.summary.entry-summary > div.mspc-wrapper.mspc-clearfix.mspc-module-accordion.mspc-auto-next.mspc-step-by-step > div > div:nth-child(8) > div > div')
print('Options under options panel 3 :', len(options_panel_4))
for option_4 in options_panel_4:
driver.execute_script("arguments[0].scrollIntoView();", option_4)
option_4.find_element(By.CSS_SELECTOR, 'div > div.mspc-radio.ui.radio.checkbox > input[type=radio]').click()
However, It throws exception as follows:
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element <div >...</div> is not clickable at point (890, 14). Other element would receive the click: <div >...</div>
(Session info: chrome=102.0.5005.115)
Stacktrace:
0 chromedriver 0x00000001024162c9 chromedriver 5120713
1 chromedriver 0x00000001023a4e33 chromedriver 4656691
2 chromedriver 0x0000000101f94158 chromedriver 393560
3 chromedriver 0x0000000101fd0638 chromedriver 640568
4 chromedriver 0x0000000101fce1b3 chromedriver 631219
5 chromedriver 0x0000000101fcb814 chromedriver 620564
6 chromedriver 0x0000000101fca5b2 chromedriver 615858
7 chromedriver 0x0000000101fbe249 chromedriver 565833
8 chromedriver 0x0000000101fe6482 chromedriver 730242
9 chromedriver 0x0000000101fbdb05 chromedriver 563973
10 chromedriver 0x0000000101fe658e chromedriver 730510
11 chromedriver 0x0000000101ff8f41 chromedriver 806721
12 chromedriver 0x0000000101fe6373 chromedriver 729971
13 chromedriver 0x0000000101fbc609 chromedriver 558601
14 chromedriver 0x0000000101fbd635 chromedriver 562741
15 chromedriver 0x00000001023e8b1d chromedriver 4934429
16 chromedriver 0x00000001023ed295 chromedriver 4952725
17 chromedriver 0x00000001023f23cf chromedriver 4973519
18 chromedriver 0x00000001023edcba chromedriver 4955322
19 chromedriver 0x00000001023c837c chromedriver 4801404
20 chromedriver 0x0000000102407c68 chromedriver 5061736
21 chromedriver 0x0000000102407def chromedriver 5062127
22 chromedriver 0x000000010241d5e5 chromedriver 5150181
23 libsystem_pthread.dylib 0x00007ff80f3874e1 _pthread_start 125
24 libsystem_pthread.dylib 0x00007ff80f382f6b thread_start 15
CodePudding user response:
As you want to get datas about all products, so I would get all xpaths of checkboxes, for example '//input[@type="radio" and @value="jaguar-f-type-f-pace-xe-xf-xj"]'. When I will have all xpaths, I will do a script to select all options and I will finish get the text of this xpath '//*[@]/descendant::span[@]'
CodePudding user response:
What the error code is telling you is that the problem is when you scroll down, the top menu is over the radio input. So, if it where to click on it, it would't click the radio it'd click the menu.
Also it doesn't let you select the radio itself you hafe to select a certain div, here's the xpath to that div:/html/body/div[3]/div/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[4]/div/div[2]
I made a quick try scrolling manually and selecting the previous options manually as well and it selected correctly:
import time
from selenium import webdriver
driver = webdriver.Chrome(executable_path = "chromedriver.exe")
driver.get("https://www.velocityap.com/product/3-0l-v6-supercharged-jaguar-land-rover-aj126-ecu-tuning/")
options_panel_4 = driver.find_elements_by_css_selector('div.summary.entry-summary > div.mspc-wrapper.mspc-clearfix.mspc-module-accordion.mspc-auto-next.mspc-step-by-step > div > div:nth-child(8) > div > div')
time.sleep(15)
print('Options under options panel 3 :', len(options_panel_4))
for option_4 in options_panel_4:
option_4.find_element_by_xpath('/html/body/div[3]/div/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[4]/div/div[2]').click()
I use xpath because i prefere it, it does not mean you also have to.