File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55class WebResponse :
66 def __init__ (self ):
7- pass
7+ self .default_site = ""
8+ self .headers = {}
9+ self .datas = {}
810
911 def response_html (self , site = None , header = None ):
1012 target_url = site if site else self .default_site
11-
13+ # print(header)
1214 try :
1315 response = requests .get (target_url )
1416 response .raise_for_status ()
1517 json_data = json .loads (response .content )
1618 week = [* json_data ["titleListMap" ].keys ()]
1719 for w in week :
20+ data_title , data_score = [], []
1821 contents = [* json_data ['titleListMap' ][w ]]
19- print (f"\n ===== 요일 : { w } ====== \n " )
22+ # print(f"\n ===== 요일 : {w} ====== \n")
2023 for i in contents :
21- print (f"제목 : { i ['titleName' ]} , 별점 = { round (i ['starScore' ],2 )} 점" )
22- return json_data
24+ # print(f"요일 : {w}, 제목 : <<{i['titleName']}>> , 별점 = {round(i['starScore'],2)} 점")
25+ data_title .append (i ['titleName' ])
26+ data_score .append (i ['starScore' ])
27+ self .datas [w ] = {'title' : data_title , 'score' : data_score }
28+ return self .datas
2329
2430 except requests .exceptions .RequestException as e :
2531 print (f"Error = { e } " )
You can’t perform that action at this time.
0 commit comments