Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gaganmanku96/b31831854a68ffb8c9773d3c755fbd40 to your computer and use it in GitHub Desktop.
Save gaganmanku96/b31831854a68ffb8c9773d3c755fbd40 to your computer and use it in GitHub Desktop.
Code to scrape data from a test website
def main():
URL = "https://webscraper.io/test-sites/e-commerce/allinone"
driver = get_driver()
driver.get(URL)
driver.implicitly_wait(10)
products = driver.find_elements(By.XPATH, '//div[@class="col-sm-4 col-lg-4 col-md-4"]')
for product in products:
product_title = product.find_element(By.XPATH, './/a[@class="title"]').text
product_price = product.find_element(By.XPATH, './/h4[@class="pull-right price"]').text
product_description = product.find_element(By.XPATH, './/p[@class="description"]').text
product_reviews_count = product.find_element(By.XPATH, './/div[@class="ratings"]').text
print(product_title, product_price, product_description)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment