목차
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
Beautiful Soup Documentation — Beautiful Soup 4.12.0 documentation
Beautiful Soup Documentation Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers h
www.crummy.com
import requests
from bs4 import BeautifulSoup
# requests.get(url1).content # binary string
msg=requests.get(url1).text
soup=BeautifulSoup(msg,'html.parser')
# soup.find_all('section',id='kinds-of-objects')
# list(soup.find(class_='body').children)
# soup.css.select_one('.body h2').next_element.get_text
arr1=[]
for h1 in soup.select('.body h1'):
arr1.append(h1.get_text())
print(arr1)
soup.css.select_one('.body').css.select_one('h1').next_sibling.next_sibling
arr2=[]
for h1 in soup.css.select_one('.body').css.select('h1'):
# arr2.append(h1.next_sibling.next_sibling)
arr2.append(h1.next_element.get_text())
arr2
'100일 챌린지 > 빅데이터기반 인공지능 융합 서비스 개발자' 카테고리의 다른 글
Day 89 - scikit-learn (0) | 2024.12.04 |
---|---|
Day 89 - 데이터 활용해서 모델 만들기 (0) | 2024.12.04 |
Day 88 - web scraping (1) (0) | 2024.12.03 |
Day 88 - Numpy, pandas, matplotlib (0) | 2024.12.03 |
Day 88 - Anaconda 설치하기 / Jupyter Notebook 실행하기 (0) | 2024.12.03 |