<태그 속성="속성값">내용
- 태그와 속성은 특정 목적에 따라 임의로 이름을 정해서 사용
- 다른 요소와 그룹으로 묶을 수도 있음
다음과 같이 출력 : 도시별 가장 시간대가 빠른 때의 기상예측 --------- 서울: 구름조금 인천: 구름조금 ---------
다음 셀에 다음 코드를 넣고 다음 마지막 문장을 입력하여 코드를 완성하시오 from bs4 import BeautifulSoup import requests import datetime import json info_url = 'http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=109' response = requests.get(info_url) soup = BeautifulSoup(response.content, 'lxml') locations = soup.find_all('location') for location in locations: [----------------------------------------------------------------------]
from bs4 import BeautifulSoup
import requests
import datetime
import json
info_url = 'http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=109'
response = requests.get(info_url)
soup = BeautifulSoup(response.content, 'html.parser')
locations = soup.find_all('location')
for location in locations:
print(location.find('city').text, ":", location.find('wf').text)
'거래금액', '년', '법정동', '아파트', '월', '일', '전용면적', '지번', '지역코드', '층'
day1_data_science_crawling.ipynb 파일의 3.2. Open API(Rest API)를 활용한 초간단 크롤링 실습 예제 코드 참고
JSON 포멧 예
{ "id":"01", "language": "Java", "edition": "third", "author": "Herbert Schildt" }
출처: http://dpug.tistory.com/67#.WbycWshJaUk [퍼그의 전초기지]