| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- """
- @author: luojunhui
- @description: try to get some more accounts
- """
- import datetime
- from applications.api.feishu_api import FeishuSheetApi
- from tasks.crawler_accounts_by_association import ChannelsAccountCrawler
- from tasks.crawler_accounts_by_association import ToutiaoAccountCrawler
- from tasks.crawler_accounts_by_association import HaoKanAccountCrawler
- document_token = "BGQCsOXwHhVRq5tswjgcI8NInqd"
- toutiao_sheet_id = "pIJSt7"
- channels_sheet_id = "ee0163"
- haokan_sheet_id = 'tfftfD'
- def insert_data_into_feishu_sheet(platform: str, data_list: list[list[str]]) -> None:
- """
- insert data info into feishu sheet
- :param platform: str, channels or toutiao
- :param data_list: list[list[str]],
- """
- video_array = [
- list(i) + [datetime.date.today().strftime("%Y-%m-%d")] for i in data_list
- ]
- feishu_sheet = FeishuSheetApi()
- feishu_sheet.fetch_token()
- match platform:
- case "toutiao":
- sheet_id = toutiao_sheet_id
- case "sph":
- sheet_id = channels_sheet_id
- case 'hksp':
- sheet_id = haokan_sheet_id
- case _:
- raise RuntimeError("platform error")
- feishu_sheet.prepend_value(
- sheet_token=document_token,
- sheet_id=sheet_id,
- values=[["******"]],
- ranges="A2:A2",
- )
- feishu_sheet.insert_value(
- sheet_token=document_token,
- sheet_id=sheet_id,
- values=video_array,
- ranges="A2:J{}".format(2 + len(video_array)),
- )
- def deal_each_platform(platform: str) -> None:
- """
- deal each platform
- :param platform: str, channels or toutiao
- """
- match platform:
- case "toutiao":
- crawler = ToutiaoAccountCrawler()
- case "sph":
- crawler = ChannelsAccountCrawler()
- case "hksp":
- crawler = HaoKanAccountCrawler()
- case _:
- raise RuntimeError("platform error")
- # start process
- crawler.deal()
- if __name__ == "__main__":
- # platform_list = ["sph", "hksp", "toutiao"]
- # for platform_id in platform_list:
- # deal_each_platform(platform=platform_id)
- HaoKanAccountCrawler().deal()
|