try:
driver.find_element_by_css_selector('.holiday_notice_close a').click()
except:
print('현재 팝업창이 없습니다.')
print()로 예상되는 문제 직접 적어 출력

# 팝업창 닫기
from selenium.common.exceptions import NoSuchElementException
try:
driver.find_element_by_css_selector('.holiday_notice_close a').click()
except NoSuchElementException as e:
print(e)
sql = "insert into coffee_store (brand, name, gu_name, address, lat, lng) values (1,%s,%s,%s,%s,%s)"
for content in tqdm_notebook(seoul_list):
name = content['data-name'] # 매장 이름,
address = content.select_one('p').text[:-9] # 주소
gu_name = address.split()[1] # 구 이름
lat = content['data-lat'] # 위도
lng = content['data-long'] # 경도
cur.execute(sql, (name,gu_name,address,lat,lng))
local.commit()
sql = "select ~~ " + \
"from ~~ " + \
"where ~"
import pandas as pd
num_fields = len(cur.description)
field_names = [i[0] for i in cur.description]
df = pd.DataFrame(store)
df.columns = field_names


index=False 옵션을 넣어주면 index number없이 바로 컬럼값들이 들어간다!
cur.execute('select * from tableName')
result=cur.fetchall()
for row in result:
print(row)
df.to_csv('coffe_output.csv', index=False, encoding='utf-8-sig')