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

   Á¶È¸ 3127   Ãßõ 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 1160/5609
2015-12   1122438   ¹é¸Þ°¡
2014-05   4573442   Á¤ÀºÁØ1
2019-08   2638   Enzo07
2019-08   18136   ³ª³ª³ª³ª³ª
2019-08   3236   ¹è°¡³ª¿Ô¾î
2019-08   2990   ¿©¿ìpc
2019-08   2425   ±è°Ç¿ì
2019-08   3051   Ŭ¶ôÅ°
2019-08   2837   »ßµ¹À̽½ÇÄÀÌ
2019-08   5353   È¥ÀÚ°¡´Â±æ
2019-08   7645   2CPUI±è¼¼ÈÆ
2019-08   2383   ¼­¿ïI±èµ¿¼ö
2019-08   2867   ¿©¿ìpc
2019-08   2333   °Ü¿ï³ª¹«
2019-08   4727   ¹Ý¼º¸¸
2019-08   3604   twopaik
2019-08   2879   dotlee
2019-08   5067   °¡À»¹Ù¶÷
2019-08   2089   »ßµ¹À̽½ÇÄÀÌ
2019-08   4825   ºÀ·¡
2019-08   3118   iryna7
2019-08   2641   À嵿°Ç2014