I am using python/selenium to extract two phone numbers and then save the results to a sqlite3 database. On some pages there is only one phone number, when this happens I get this error:-
sqlite3.OperationalError: table IRELAND has 7 columns but 6 values were supplied
The table has two columns for storing phone numbers PHONE1 CHAR(20), PHONE2 CHAR(20).
Is it possible to insert a 0 (Zero) when no value is found?
My Code :-
phones = browser.find_elements_by_class_name("phone")
for phone in phones:
print phone.text
query += ",\'"+phone.text+"\'"
Thanks in advance for your help.
phones = browser.find_elements_by_class_name("phone")
for i in range(0,2):
print phones[1]
if phones[i]:
query += ",\'"+phones[i].text+"\'"
else:
query += ",\'0\'"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.