From cf10ab13ca57690ed52ad0ec39ac3ca76cc1155b Mon Sep 17 00:00:00 2001 From: Redsandy <34872843+Redsandyg@users.noreply.github.com> Date: Sun, 17 Apr 2022 19:01:06 +0300 Subject: [PATCH] Update InvestCal.py --- News/InvestCal.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/News/InvestCal.py b/News/InvestCal.py index 17f63c7..4e86f9e 100644 --- a/News/InvestCal.py +++ b/News/InvestCal.py @@ -20,7 +20,7 @@ def f_write(driver): def investingPars(path_file=None,dateDict=None): ans=None op=webdriver.FirefoxOptions() - op.add_argument("--headless") + #op.add_argument("--headless") url='https://ru.investing.com/economic-calendar/' #driver = webdriver.Firefox(executable_path='C:\\Users\\Redsandy\\Downloads\\geckodriver.exe') EXE_PATH = r'C:\\Users\\Redsandy\\Downloads\\geckodriver.exe' @@ -96,21 +96,24 @@ def getDF(doc,path_file): for i in range(0, len(tdList)): - if tdList[i][0]["class"][0]=='theDay': - colDate = tdList[i][0].text[:-3] - else: - newRow={ - col_names[0]:getTime(tdList[i][0]), - col_names[1]:tdList[i][1].text.strip(), - col_names[2]:getValat(tdList[i][2]), - col_names[3]:tdList[i][3].text.strip(), - col_names[4]:getUrl(tdList[i][3]), - col_names[5]:tdList[i][4].text.strip(), - col_names[6]:tdList[i][5].text.strip(), - col_names[7]:tdList[i][6].text.strip(), - col_names[8]:colDate - } - df=df.append(newRow, ignore_index=True) + try: + if tdList[i][0]["class"][0]=='theDay': + colDate = tdList[i][0].text[:-3] + else: + newRow={ + col_names[0]:getTime(tdList[i][0]), + col_names[1]:tdList[i][1].text.strip(), + col_names[2]:getValat(tdList[i][2]), + col_names[3]:tdList[i][3].text.strip(), + col_names[4]:getUrl(tdList[i][3]), + col_names[5]:tdList[i][4].text.strip(), + col_names[6]:tdList[i][5].text.strip(), + col_names[7]:tdList[i][6].text.strip(), + col_names[8]:colDate + } + df=df.append(newRow, ignore_index=True) + except: + pass if path_file!=None: df.to_csv(path_file, index=False, encoding='utf-8-sig')