Esempio n. 1
0
 def _parse_li(li):
     shop_name = li.find("a", {
         "class": "list-rst__rst-name-target"
     }).text
     rank_num = li.find("i", {
         "class": "c-ranking-badge__contents"
     }).text
     shop_link = li.find("a", {
         "class": "list-rst__rst-name-target"
     }).get("href")
     shop_target = li.find("span", {
         "class": "list-rst__area-genre"
     }).text
     shop_photo = li.find("p", {
         "class": "list-rst__photo-item"
     }).find("img").get("src")
     shop_start = li.find("span", {
         "class": "c-rating__val c-rating__val--strong"
     }).text
     shop_review_count = li.find("a", {
         "class": "list-rst__rvw-count-target"
     }).text.split("件")[0]
     shop_review_link = li.find("a", {
         "class": "list-rst__rvw-count-target"
     }).get("href")
     shop_budget = li.findAll("span",
                              {"class": "cpy-dinner-budget-val"})
     shop_diner_budget = shop_budget[0].text
     shop_lunch_budget = shop_budget[1].text
     detail: DetailSite = DetailSite(self.request, shop_link)
     shop_pr_comment = detail.pr_comment
     shop_pr_comment_title = shop_pr_comment["pr_comment_title"]
     shop_pr_comment_first = shop_pr_comment["pr_comment_first"]
     # list-rst__comment-item
     shop_comments = ",".join(
         list(
             map(lambda x: x.find("strong").text,
                 li.findAll("li",
                            {"class": "list-rst__comment-item"}))))
     return RankedItem(rank_keyword=keyword,
                       rank_num=rank_num,
                       shop_name=shop_name,
                       shop_link=shop_link,
                       shop_target=shop_target,
                       shop_photo=shop_photo,
                       shop_start=shop_start,
                       shop_review_count=shop_review_count,
                       shop_review_link=shop_review_link,
                       shop_diner_budget=shop_diner_budget,
                       shop_lunch_budget=shop_lunch_budget,
                       shop_comments=shop_comments,
                       shop_pr_comment_title=shop_pr_comment_title,
                       shop_pr_comment_first=shop_pr_comment_first,
                       update_date=get_today_date())
Esempio n. 2
0
 def _parse(j) -> NHKProgram:
     return NHKProgram(id=j["id"],
                       event_id=j["event_id"],
                       start_time=j["start_time"],
                       end_time=j["end_time"],
                       area_id=j["area"]["id"],
                       area_name=j["area"]["name"],
                       service_id=j["service"]["id"],
                       service_name=j["service"]["name"],
                       title=j["title"],
                       subtitle=j["subtitle"],
                       content=j["content"],
                       act=j["act"],
                       genres=",".join(j["genres"]),
                       update_date=get_today_date())
Esempio n. 3
0
 def program_list(cls, api_key, area="130", service="g1", date=None) -> List[NHKProgram]:
     request = CatsRequest()
     with CatsRequest() as request:
         if date == None:
             date = get_today_date(split="-")
         try:
             api_url = f"http://api.nhk.or.jp/v2/pg/list/130/g1/{date}.json?key={api_key}"
             logging.info(f"api_url: {api_url}",sys._getframe().f_code.co_name)
             json = request.get(url=api_url, response_content_type="json").content
             logging.debug(f"response: {json}",sys._getframe().f_code.co_name)
             result = NHKProgramTable.parse_response(response_json=json)
             return result
         except Exception:
             sys.exc_info()
             logging.error(f"{sys._getframe().f_code.co_name} was failed. {sys.exc_info()}")
Esempio n. 4
0
class AllGunosyRanking:
    gunosy_rankings: List[GunosyRanking]
    update_date: str = get_today_date()
Esempio n. 5
0
class GunosyRanking:
    ranking_title: str
    articles: List[GunosyArticle]
    update_date: str = get_today_date()
Esempio n. 6
0
class AllNataliePopular:
    natalie_populares: List[NataliePopular]
    update_date: str = get_today_date()
Esempio n. 7
0
class NataliePopular:
    natalie_populare_pages: List[NataliePopularPage]
    update_date: str = get_today_date()
Esempio n. 8
0
class NataliePopularPage:
    populer_url: str
    popular_category: str
    natalie_articles: List[NatalieArticle]
    update_date: str = get_today_date()