我想将此数据输出到一个csv文件。当前,到达css_selector
时未附加任何内容。我想将其附加到列表,然后添加到数据框,再添加到csv文件。
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)
我该如何解决问题?