티스토리 뷰

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import requests

from bs4 import BeautifulSoup

 

def get_bs_obj(company_code):

    url = "https://finance.naver.com/item/main.nhn?code=" + company_code

    result = requests.get(url)

    bs_obj = BeautifulSoup(result.content, "html.parser")

    return bs_obj

 

# bs_obj를 받아서 price 를 return하게

def get_price(company_code):

    bs_obj = get_bs_obj(company_code)

    no_today = bs_obj.find ("p", {"class":"no_today"})

    blind_now = no_today.find("span", {"class":"blind"})

    return blind_now.text

 

company_codes = ["005930""017670""000100" ]

# Samsung 005930

# sk telecom 017670

# Youhan

for item in company_codes:

    price = get_price(item)

    print(price)

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함