-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkb_report_scroll.py
More file actions
36 lines (30 loc) · 1.15 KB
/
kb_report_scroll.py
File metadata and controls
36 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# kb 비타민 크롤링 해오기
import pandas as pd
import requests
from bs4 import BeautifulSoup
from news.models import column
class kb_report:
def __init__(self):
self.kb_url = "https://www.kbfg.com/kbresearch/vitamin/reportList.do"
self.num_reports = 9
self.kb_reports= []
def requests(self):
html = requests.get(self.kb_url).text
parser = BeautifulSoup(html,'html.parser')
report_html = parser.select('td')
for i in range(self.num_reports):
title_str = str(report_html[6*i+2].select('a')[0]).split('"')
url = "https://www.kbfg.com/" + title_str[1]
title = title_str[2][1:-4]
pub_date = str(report_html[6*i+4])[4:-5]
self.kb_reports.append({"title":title, "url":url, "pub_date":pub_date})
print(self.kb_reports)
print("scrapping KB website...")
def save_db(self):
for i in range(self.num_reports):
column = Column()
column.subject = self.kb_reports[i]["title"]
column.url = self.kb_reports[i]["url"]
column.save()
test = kb_report()
test.requests()