728x90 반응형 SMALL bs42 [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. 이전 1 다음 728x90 반응형 LIST