Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import aiohttp
- import asyncio
- import time
- async def main():
- url = "https://scrapeme.live/shop/"
- # Time Tracking: Start Time
- start_time = time.time()
- # Fetching content asynchronously
- content = await fetch(url)
- # Printing content
- print(content)
- # Time Tracking: End Time
- end_time = time.time()
- # Calculating and printing the time taken
- print(f"Time taken: {end_time - start_time} seconds")
- async def fetch(url):
- # Create HTTP session
- async with aiohttp.ClientSession() as session:
- # Make GET request using session
- async with session.get(url) as response:
- # Return text content
- return await response.text()
- # Run the main function
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement