Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium_driverless import webdriver
- from selenium_driverless.types.by import By
- import asyncio
- import bs4
- async def main():
- options = webdriver.ChromeOptions()
- async with webdriver.Chrome(options=options) as driver:
- await driver.get(url='https://www.zoro.com/search?q=gloves')
- cont = input('press enter when site has loaded')
- source = await driver.page_source
- soup = bs4.BeautifulSoup(source, 'html.parser')
- for product in soup.find_all(name='div', attrs={
- 'class': 'product-card search-product-card search-results__item product-card--grid'}):
- img = product.find('img')
- if img:
- desc = img['alt']
- if desc:
- print(f'Product: {desc}')
- else:
- print('image found, but no alt desc was found')
- else:
- print('no image found, bad element?')
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment