본문 바로가기
728x90
반응형
SMALL

beautifulsoup3

[Python] 뉴스 사이트 스크랩 뉴스 사이트 스크랩 import requests url = 'https://www.boannews.com/media/t_list.asp' res = requests.get(url, verify=False) res.status_code bs4 from bs4 import BeautifulSoup bs4obj = BeautifulSoup(res.text, 'html.parser') # html을 파서를 사용해 받아온 뉴스 페이지 분석 bs4obj.title news_list = bs4obj.find_all('div', {'class':'news_list'}) len(news_list) 테이블 정리 # 제목 뽑기 news_list[0].img.text.strip() # 해당 기사의 URL 뽑기 news_lis.. 2022. 11. 24.
REST API (Webscraping) (3) Webscraping 1. from bs4 import BeautifulSoup html=" Lionel Messi Salary: $ 100,000,000 Christiano Ronaldo Salary: $ 150,000,000 Neymar Junior Saraly: $ 85,000,000 " soup = BeautifulSoup(html, 'html5lib') tag_object=soup.title tag_object=soup.h3 tag_child = tag_object.b parent_tag=tag_child.parent sibling_1 = tag_object.next_sibling tag_child.attr tag_child.string 2. from bs4 import BeautifulSoup.. 2022. 5. 11.
[Web Crawler] BeautifulSoup으로 다양한 데이터 추출하기 BeautifulSoup HTML 문서를 탐색해서 원하는 부분만 쉽게 뽑아낼 수 있는 python 라이브러리인 BeautifulSoup이 존재한다. # BeautifulSoup 설치 pip install beautifulsoup4 import requests from bs4 import BeautifulSoup url = 'https://kin.naver.com/search/list.nhn?query=%ED%8C%8C%EC%9D%B4%EC%8D%AC' response = requests.get(url) if response.status_code == 200: html = response.text soup = BeautifulSoup(html, 'html.parser') print(soup) else : .. 2022. 2. 14.
728x90
반응형
LIST