def calc_url_by_from_date(url, period1_sec, period2_sec):
    """This function takes the url and the start and ens periods and insert them in the relevant place in the url """
    prefix = url.split('history?', 1)[0] + 'history?'
    periods = 'period1=' + str(period1_sec) + '&period2=' + str(period2_sec)
    suffix = '&' + url.split('&', 2)[2]
    return prefix+periods+suffix