<jupyter_start><jupyter_text><jupyter_code>import requests
from bs4 import BeautifulSoup
import time
import pandas as pd
import numpy as np
import os<jupyter_output><empty_output><jupyter_text>Referenceshttps://docs.python-requests.org/en/master/  Request<jupyter_code>r = requests.get("https://www.wooribank.com/",
                  timeout = 15, # 1초 동안 무응답 시 에러처리
                  headers = {
                      "User-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) \
                      AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109"
                  }
                ) 
r.encoding = "utf-8" # encoding 방식 지정해주기

print(r.status_code)
print(r.encoding)
# print(r.text)
# 다른 페이지들도 가져와보기

naver_webtoon_html = requests.get("https://comic.naver.com/webtoon/weekday",
                  timeout = 15, # 1초 동안 무응답 시 에러처리
                  headers = {
                      "User-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) \
                      AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109"
                  }
                ) 
print(naver_webtoon_html.status_code)
# print(naver_webtoon_html.text) 

# 다른 페이지들도 가져와보기

melon_html = requests.get("https://www.melon.com/chart/index.htm",
                  timeout = 15, # 1초 동안 무응답 시 에러처리,
                  
                  headers = {
                      "User-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) \
                      AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109"
                  }
                ) 
print(melon_html.status_code)
# print(melon_html.text)<jupyter_output>200<jupyter_text>BeautifulSoup<jupyter_code>soup = BeautifulSoup(r.content, 'html.parser')
# print(soup.prettify())

print(soup.title)
print(soup.title.string) 
soup.select("div[class='tit-5 absolute js-display-hover']")
soup.select("div[class='tit-5 absolute js-display-hover'] li")
for item in soup.select("div[class='tit-5 absolute js-display-hover'] li"):
    print(item.text)
soup.select_one("div[class='tit-5 absolute js-display-hover'] li")
soup.find("div",{"class":"tit-5 absolute js-display-hover"})
soup.find("div",{"class":"tit-5 absolute js-display-hover"}).find_all("li")<jupyter_output><empty_output><jupyter_text>Request, BS4 실습<jupyter_code># 연습용 페이지 크롤링 (To-do)
# https://dataquestio.github.io/web-scraping-pages/ids_and_classes.html

# "First-outer paragraph" 출력해보기


# 오늘의 코스피 받아오기 (To-do)

# 네이버웹툰 https://comic.naver.com/webtoon/weekday 실시간 인기 급상승 웹툰 1위-10위 제목 뽑아보기

# National Weather Service 페이지 크롤링
# https://forecast.weather.gov/MapClick.php?lat=37.7772&lon=-122.4168#.Yk05PBNBxFw

# 시간별 날씨 (To-do)
# https://weather.naver.com/today/
# 시간대별로 날씨 뽑아와서 dictionary에 저장하기

# Challenging

# Melon playlist 
# https://www.melon.com/chart/index.htm
# 1위-100위 노래 제목 뽑기<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1364755539922617, 'fraction_numerical': 0.03833978192050651, 'mean_word_length': 2.7470355731225298, 'pattern_counts': {'":': 2, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 9, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '514000', 'license': 'MIT', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1284, 'n_words': 181, 'path': 'Day 4/4_1.data_scraping.ipynb', 'repo_name': 'SLCFLAB/Data-Science-Python', 'size': '2843'}