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

   Á¶È¸ 3105   Ãßõ 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 1146/5594
2015-12   1046948   ¹é¸Þ°¡
2014-05   4494573   Á¤ÀºÁØ1
2019-08   2313   °Ü¿ï³ª¹«
2019-08   4697   ¹Ý¼º¸¸
2019-08   3545   twopaik
2019-08   2835   dotlee
2019-08   4988   °¡À»¹Ù¶÷
2019-08   2072   »ßµ¹À̽½ÇÄÀÌ
2019-08   4793   ºÀ·¡
2019-08   3099   iryna7
2019-08   2625   À嵿°Ç2014
2019-08   3442   ±ô¹Ú±ô¹Ú°¡
2019-08   8506   È­¶õ
2019-08   2894   refreshair
2019-08   3462   ¿À¿ùÀÇÇູ
2019-08   3373   Doker
2019-08   2644   winner712
2019-08   3401   Stiff
2019-08   2301   ¿ÉÅ×·ÐÀÔ¹®
2019-08   2090   ocarina
2019-08   3196   ¼­¹ö³ª¶ó
2019-08   2520   ¸í¼ºÈ£