안녕하세요 파린이입니다 크롤링 진행 중인데 데이터가 저장이 안되네요.

조회수 766회

http://kctc.kribb.re.kr 이라는 생물자원사이트에서 생물자원 리스트를 크롤링하는 프로그램을 제작중입니다. 그런데 데이터가 제대로 저장되다가 안되나가 해서 뭐가 문제인지 고견을 듣고 싶습니다. 이미지 from selenium import webdriver from bs4 import BeautifulSoup import pandas as pd import multiprocessing base_url = 'https://kctc.kribb.re.kr/jsearch/j_sview.aspx?sn={}' results = [] options = webdriver.ChromeOptions() options.add_argument('headless') options.add_argument("disable-gpu") def kctc(name): for n in range(3000, 3010): url = base_url.format(n + 1) driver = webdriver.Chrome("C:/chromedriver.exe", chrome_options=options) driver.implicitly_wait(5) driver.get(url) html = driver.page_source soup = BeautifulSoup(html, "html.parser") tds = soup.find_all("td") ths = soup.find_all("th") if ths[0].get_text().strip != "KCTC No.": driver.close() continue KCTC_No = tds[0].get_text().strip() Strain = tds1.get_text().strip() Kind = tds[2].get_text().strip() Other_Collection = tds[7].get_text().strip() Source = tds[8].get_text().strip() Product = tds[9].get_text().strip() Protduct2 = tds[10].get_text().strip() Aero_Condition = tds[11].get_text().strip() Application = tds[12].get_text().strip() Temperature = tds[13].get_text().strip() KCTC_Media_No = tds[14].get_text().strip() Biosafety_level = tds[15].get_text().strip() results.append( (KCTC_No, Strain, Kind, Other_Collection, Source, Product, Protduct2, Aero_Condition, Application, Temperature, KCTC_Media_No, Biosafety_level)) table = pd.DataFrame(results, columns=['KCTC No', 'Strain', 'Kind', 'Other Collection', 'Source', 'Product', 'Protduct2', 'Aero Condition', 'Application', 'Temperature', 'KCTC Media No', 'Biosafety level']) with open('KCTC list 02.csv', 'wb') as f: writer = csv.writer(f, csv.excel) table.to_csv('KCTC list 02.csv') driver.quit() num_list = ['p1', 'p2'] if name == 'main': pool = multiprocessing.Pool(processes=2) pool.map(kctc, num_list) pool.close() pool.join() print("끝났다")

띄어쓰기가 다 없어졌네요 ㅠㅠ 어떻게 해야제대로 코드올릴수 있나요? 처음에는 저장이 되는듯 하더니 손보니까 저장이 안되는 이상한....게 되었습니다. 왜 csv파일로 저장이 안되는지 해결 부탁드려요 ㅠ

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)