Update InvestCal.py
This commit is contained in:
parent
d3ea17481e
commit
cf10ab13ca
@ -20,7 +20,7 @@ def f_write(driver):
|
|||||||
def investingPars(path_file=None,dateDict=None):
|
def investingPars(path_file=None,dateDict=None):
|
||||||
ans=None
|
ans=None
|
||||||
op=webdriver.FirefoxOptions()
|
op=webdriver.FirefoxOptions()
|
||||||
op.add_argument("--headless")
|
#op.add_argument("--headless")
|
||||||
url='https://ru.investing.com/economic-calendar/'
|
url='https://ru.investing.com/economic-calendar/'
|
||||||
#driver = webdriver.Firefox(executable_path='C:\\Users\\Redsandy\\Downloads\\geckodriver.exe')
|
#driver = webdriver.Firefox(executable_path='C:\\Users\\Redsandy\\Downloads\\geckodriver.exe')
|
||||||
EXE_PATH = r'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)):
|
for i in range(0, len(tdList)):
|
||||||
if tdList[i][0]["class"][0]=='theDay':
|
try:
|
||||||
colDate = tdList[i][0].text[:-3]
|
if tdList[i][0]["class"][0]=='theDay':
|
||||||
else:
|
colDate = tdList[i][0].text[:-3]
|
||||||
newRow={
|
else:
|
||||||
col_names[0]:getTime(tdList[i][0]),
|
newRow={
|
||||||
col_names[1]:tdList[i][1].text.strip(),
|
col_names[0]:getTime(tdList[i][0]),
|
||||||
col_names[2]:getValat(tdList[i][2]),
|
col_names[1]:tdList[i][1].text.strip(),
|
||||||
col_names[3]:tdList[i][3].text.strip(),
|
col_names[2]:getValat(tdList[i][2]),
|
||||||
col_names[4]:getUrl(tdList[i][3]),
|
col_names[3]:tdList[i][3].text.strip(),
|
||||||
col_names[5]:tdList[i][4].text.strip(),
|
col_names[4]:getUrl(tdList[i][3]),
|
||||||
col_names[6]:tdList[i][5].text.strip(),
|
col_names[5]:tdList[i][4].text.strip(),
|
||||||
col_names[7]:tdList[i][6].text.strip(),
|
col_names[6]:tdList[i][5].text.strip(),
|
||||||
col_names[8]:colDate
|
col_names[7]:tdList[i][6].text.strip(),
|
||||||
}
|
col_names[8]:colDate
|
||||||
df=df.append(newRow, ignore_index=True)
|
}
|
||||||
|
df=df.append(newRow, ignore_index=True)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if path_file!=None:
|
if path_file!=None:
|
||||||
df.to_csv(path_file, index=False, encoding='utf-8-sig')
|
df.to_csv(path_file, index=False, encoding='utf-8-sig')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user