'Python Multi-threading, how to get the class I want
I am following a multi-threading tutorial but have trouble understanding it. The tutorial returns r as an int, but I am looking for <class 'requests.models.Response'>. I want to be able to pass this into pd.read_html as r.text to scrape data. I appreciate any help.
url_list = ["https://finance.yahoo.com/quote/"+str(STOCK)+"/analysis?p="+str(STOCK)+"","https://www.marketwatch.com/investing/stock/"+str(STOCK)+"/financials/cash-flow"]
def download_file(url):
html = requests.get(url, headers = headers, stream=True) #headers = User Agent
return html.status_code
processes = []
with ThreadPoolExecutor(max_workers=10) as executor:
for url in url_list:
processes.append(executor.submit(download_file, url))
for task in as_completed(processes):
r = task.result()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
