STUDY/CRAWLING

[CRAWLING] beautifulsoup-kema

BOTTLE6 2022. 5. 28. 00:21

finding url

 

417 = 410 + 7 

# kema
url = 'http://www.k-ets.or.kr/bbs/board.php?bo_table=s6_1'
res = requests.get(url)
soup = BeautifulSoup(res.text, 'html.parser')

# find 410
for i in soup.find_all('div', class_='div_td col_num'):
    temp = i.get_text().strip()
    if temp.isdigit():
        point = temp
        print(point)
        break
url2 = 'http://www.k-ets.or.kr/bbs/board.php?bo_table=s6_1&wr_id={}'.format(int(point)+7)
res2 = requests.get(url2)
soup2 = BeautifulSoup(res2.text, 'html.parser')

crawling 

soup2.select('#bo_v_con')

for i in soup2.select('#bo_v_con')[0].find_all('p'):
    print(i.text.strip())

another way

for i in soup2.find_all('p'):
    print(i.text.strip())