问题
I want to output this data to a csv file. Currently, it's not appending anything when getting to the css_selector
the text is not being appended. I want to append it to a list, then in a dataframe and then to a csv file.
list1=[]
for i, j in df1.iterrows():
name = j[1]
id1 = j[2]
sleep(3)
BI_box = WebDriverWait(driver,
10).until(EC.presence_of_element_located((By.ID,'BI')))
BI_box.send_keys(id1)
Last_Name_box = WebDriverWait(driver,
10).until(EC.presence_of_element_located((By.ID,'last')))
Last_Name_box.send_keys(name)
Sea= WebDriverWait(driver,
10).until(EC.presence_of_element_located((By.ID,'srch')))
Sea.click()
try:
elm_result = driver.find_element_by_css_selector("span.flex[ng-
bind='(lbecord.F)']").text
list1.append(elm_result)
print(elm_result)
print(list1)
except:
pass
try:
elm_result4 = driver.find_element_by_css_selector("span.flex[ng-
bind^='(la.record.B_DT ']").text
list1.append(elm_result4)
except:
pass
try:
elm_result12 = driver.find_element_by_css_selector("span[ng-
bind='row.RISK_IND']").text
list1.append(elm_result12)
except:
pass
sleep(2)
clear_btn = driver.find_element_by_id('clr')
clear_btn.click()
sleep(2)
print(list1)
How do I solve the problem?
来源:https://stackoverflow.com/questions/57368284/how-do-i-output-data-to-a-csv-file-with-headers