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

   Á¶È¸ 3285   Ãßõ 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 1211/5654
2015-12   1385717   ¹é¸Þ°¡
2014-05   4841234   Á¤ÀºÁØ1
2004-07   7539   ¿À¿øÅÃ
2020-09   7538   º´µû°³´Ô
2008-02   7538   ¹ÚÁø±¹
2010-05   7538   Àü±ÙÇö
2009-03   7538   ±è°Ç¿ì
2006-04   7538   ±èÅÂÈÆ
2010-03   7537   ½ÂÈĴϵµÄì
2011-01   7537   ±èÀå¿ì
2008-06   7537   ¹æÈ¿¹®
2004-07   7537   ±èÁøÀÏ
2006-04   7537   ȲÇýÁø
2014-10   7537   À嵿°Ç2014
2017-02   7536   ¸¼Àº¿©¸§
2013-10   7536   SkyBase
2006-05   7535   È«¼öÇõ
2013-02   7535   Ȳ½ÂÇö
2011-06   7535   ±èÁø±Ô
2010-09   7535   ¹æoÈ¿o¹®
2015-01   7535   izegtob
2005-10   7535   Çϼö¾ð