Posts

Showing posts with the label concurrent.futures

Concurrent futures webscraping

Image
Clash Royale CLAN TAG #URR8PPP Concurrent futures webscraping whoever is reading his! Thank you for taking the time to look at this. I am currently trying to develop a fast webscraping function so I can scrape a large list of files. This is the code I have currently: import time import requests from bs4 import BeautifulSoup from concurrent.futures import ProcessPoolExecutor, as_completed def parse(url): r = requests.get(url) soup = BeautifulSoup(r.content, 'lxml') return soup.find_all('a') with ProcessPoolExecutor(max_workers=4) as executor: start = time.time() futures = [ executor.submit(parse, url) for url in URLs ] results = for result in as_completed(futures): results.append(result) end = time.time() print("Time Taken: {:.6f}s".format(end-start)) this brings backs results for websites i.e www.google.com, however my problem is I have no idea to view the data it brings back I only get future objects. Please can som...