I want to create a crawler/scraper. And the element which I want to crawl, In my opinion serving JS. And on my browser I can see that element but on webdriver I cannot see this.
For example; URL : https://www.hotic.com.tr/p/hakiki-deri-camel-erkek-cuzdan-168675?_sgm_campaign=scn_2a06ce3c78082000&_sgm_source=168675&_sgm_action=click
And On my browser I can see element like that:
But on chrome webdriver I cannot see that element like that:
And my webdriver code like that:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.hotic.com.tr/p/hakiki-deri-camel-erkek-cuzdan-168675?_sgm_campaign=scn_2a06ce3c78082000&_sgm_source=168675&_sgm_action=click")
driver.quit()
On my browser I just click the URL. I have no user account or promo code.
How can I get this element on webdriver chrome?
To get the value Sepette %30 İndirim: 153.30 TL
use WebDriverWait()
and wait for element_to_be_clickable()
and following css selector
.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.hotic.com.tr/p/hakiki-deri-camel-erkek-cuzdan-168675?_sgm_campaign=scn_2a06ce3c78082000&_sgm_source=168675&_sgm_action=click")
print(WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"span.ins-discount-badge"))).text)
Output on console:
Sepette %30 İndirim: 153.30 TL
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments