Here a example of a working setup.
It's the same way,but use
If uncomment like this browser will not start up.
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from bs4 import BeautifulSoup import time #--| Setup options = Options() #options.add_argument("--headless") #options.add_argument("--window-size=1980,1020") #options.add_argument('--disable-gpu') browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options) #--| Parse or automation browser.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq") time.sleep(2) soup = BeautifulSoup(browser.page_source, 'lxml') # Example of using both to parse use_bs4 = soup.find('div', class_="col col-7-12") print(use_bs4.text) print('*' * 25) use_sel = browser.find_elements_by_css_selector('div > div._1vC4OE._2rQ-NK') print(use_sel[0].text)
Output:Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A14664.724,087 Ratings & 2,715 ReviewsIntel Core i5 Processor (5th Gen)8 GB DDR3 RAM64 bit Mac OS Operating System128 GB SSD33.78 cm (13.3 inch) Display1 Year Carry In Warranty
*************************
₹65,990
So this Path is for Windows,do you use Mac?It's the same way,but use
chromedriver_mac64.zip
then there is no .exe
only chromedriver
.If uncomment like this browser will not start up.
#--| Setup options = Options() options.add_argument("--headless") options.add_argument("--window-size=1980,1020") options.add_argument('--disable-gpu')