Answer the question
In order to leave comments, you need to log in
Why is the request taking so long to process?
import requests
import pandas as pd
import numpy as np
import datetime as date
import pandahouse as ph
import matplotlib.pyplot as plt
import xml.etree.ElementTree as et
from prophet import Prophet
daterange = pd.date_range('2020-06-01', '2020-10-31')
currencies = pd.DataFrame()
info_currencies = pd.DataFrame()
for single_date in daterange:
date = single_date.strftime("%d.%m.%Y")
url = 'http://www.cbr.ru/scripts/XML_daily.asp?date_req=%s' % date
root = et.fromstring(requests.get(url).content)
for item in root.findall('.//Valute'):
data = {}
for child in list(item):
data.update({child.tag: child.text})
currencies = currencies \
.append({'name': data['CharCode'], 'value': data['Value'], 'date': date}, ignore_index=True)
info_currencies = info_currencies \
.append({'name': data['CharCode'], 'dsh': data['Name']}, ignore_index=True)
Answer the question
In order to leave comments, you need to log in
If during the day everything works quickly with absolutely the same parameters, then the problem is in the Internet or the cbr.ru server. There is not much help here, except to parallelize queries instead of executing them sequentially in a loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question