Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import aiohttp
- from bs4 import BeautifulSoup
- import asyncio
- from tool import userAgents
- async def main():
- url = "https://www.amazon.se/s?k=intel"
- headers = {
- "User-Agent": userAgents()
- }
- async with aiohttp.ClientSession() as session:
- async with session.get(url, headers=headers) as response:
- html = await response.text()
- # return html
- soup = BeautifulSoup(html, "html.parser")
- # return soup.prettify()
- products = soup.select_one("div[data-component-type='s-search-result']")
- # return products
- for product in products:
- # title = product.find("a", _class="a-link-normal a-text-normal").text
- title = product.select_one("a.a-link-normal.a-text-normal").text
- # price = product.find("span", _class="a-price").text
- price = product.select_one("span.a-price").text
- print(f"Title: {title}")
- print(f"Price: {price}")
- if __name__ == '__main__':
- print(asyncio.run(main()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement