ÆÄÀ̽ã Å©·Ñ¸µ ÀßÇϽôºРµµ¿ò ¿äûµå¸³´Ï´Ù...

   Á¶È¸ 3290   Ãßõ 0    

http://hkconsensus.hankyung.com/apps.chart/chart.chartList?callback=jQuery112406638263512384042_1563692725032&report_type=CO&business_code=005930&_=1563692725033


위 사이트에서 정보를 좀 긁어오려하는데 아래와같이 코드를 짜도 아무 결과를 내어놓지를 않아서...질문을 드립니다.

또한 위의 파란색 음영부분을 txt파일에 100개정도 저장해놓고 순차적으로 결과치를 txt파일이나 엑셀파일로 저장하려는데 방법이 있을까요?



from urllib.request import urlopen

from bs4 import BeautifulSoup

html = urlopen("http://hkconsensus.hankyung.com/apps.chart/chart.chartList?callback=jQuery112406638263512384042_1563692725032&report_type=CO&business_code=005930&_=1563692725033")

soup = BeautifulSoup(html, "lxml")

print(soup)

ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
NaN 2019-07
À§ÀÇ ÆĶõ»ö À½¿µºÎºÐÀ» txtÆÄÀÏ¿¡ 100°³Á¤µµ ÀúÀåÇسõ°í ¼øÂ÷ÀûÀ¸·Î °á°úÄ¡ -> txtÆÄÀÏÀ» ¶óÀκ°·Î ó¸®ÇϽøéµË´Ï´Ù.
https://stackabuse.com/read-a-file-line-by-line-in-python/
»ó±â ¸µÅ©ÀÇ ´ÙÀ½ºÎºÐÀ» Âü°íÇϽøéµË´Ï´Ù.

 filepath = 'Iliad.txt'
with open(filepath) as fp:
  line = fp.readline()
  cnt = 1
  while line:
      print("Line {}: {}".format(cnt, line.strip()))
      line = fp.readline()
      cnt += 1
     
°¨»çÇÕ´Ï´Ù~!
±Ùµ¥...Ȥ½Ã À§ÀÇ °á°ú°¡ ¿Ö ¾È³ª¿À´ÂÁö ¾Ë¼ö ÀÖÀ»±î¿ä?
Èñ¾ÈÇÏ°Ô ¾Æ¹«·± °á°ú°¡ ³ª¿ÀÁú ¾Ê½À´Ï´Ù....
NaN 2019-07
°á°úÄ¡¸¦ txtÆÄÀÏÀ̳ª ¿¢¼¿ÆÄÀÏ·Î ÀúÀåÇÏ·Á´Âµ¥ ¹æ¹ýÀÌ ÀÖÀ»±î¿ä -> ÆÄÀ̼±ÀÇ csv ¶óÀ̺귯¸®¸¦ ¾²½Ã¸éµË´Ï´Ù.
csvÀÇ writerºÎºÐÀ» Âü°íÇÏ½Ã¸é µÉ°Í°°½À´Ï´Ù.
https://realpython.com/python-csv/
¶óÀκ°·Î ·çÇÁ¸¦ »ç¿ëÇϽøé ÆÄÀÏ¿¡ ¶óÀÎÀ» Ãß°¡ÇؾßÇÏ´Ï writerow ºÎºÐµµ Âü°íÇϼžßÇÒ°Í°°½À´Ï´Ù~
Èì³Ä 2019-07
import requests


from bs4 import BeautifulSoup

url = "http://hkconsensus.hankyung.com/apps.chart/chart.chartList?callback=jQuery112406638263512384042_1563692725032&report_type=CO&business_code=005930&_=1563692725033"

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'}

html = requests.get(url,headers = headers).text
soup = BeautifulSoup(html, "lxml")


print(soup)


ÇØ´õ Á¤º¸ ¾ø¾î¼­ ±×·±°Å °°³×¿ä. ÀÌ·¸°Ô Çغ¸¼¼¿ä.
     
¿À~! µË´Ï´Ù °¨»çµå·Á¿ä~!!!


QnA
Á¦¸ñPage 1212/5654
2014-05   4844608   Á¤ÀºÁØ1
2015-12   1389315   ¹é¸Þ°¡
2021-03   3235   Á¦Á¦»ç¶û3
2015-01   3235   ¹Ù´Ù´Á´ë
2018-05   3235   ºí·ç¿µ»ó
2023-08   3235   ¹«½î»Ôó·³
2015-05   3235   ¶ó¿ÂÁ¦³ª
2014-02   3235   À©µµ¿ì10
2017-09   3235   ½½·çÇÁ
2019-12   3235   ±îÄ¡»ê°³²ÜÅÊ
2018-02   3235   ³ªÆÄÀÌ°­½ÂÈÆ
2014-02   3235   ºü¸¥°³¹Ì
2014-04   3235   ¿¥ºê¸®¿À
2016-08   3236   catstyle
2018-07   3236   Çϵ¥½º
2021-02   3236   keros
2017-03   3236   ¿Ã»©¹ÌÀá¿Í
2015-12   3236   À嵿°Ç2014
2018-11   3236   ½Ã°ñÁý³ë¾È
2021-01   3236   ¹ü¹üÀÌ
2020-07   3236   ºí·ç¿µ»ó
2016-02   3236   Çϼ¿È£ÇÁ