这是我参与8月更文挑战的第8天,活动详情查看:8月更文挑战
爬取了*jin社区LV7大神yck的掘金文章
yck传送门 点这里
request
url = "https://juejin.cn/user/xxxxxxxxx/posts"
url = "https://api.juejin.cn/content_api/v1/article/query_list"
method = "post"
header = {
"content-type":"application/json";
"cookie": ""
}
query_list = {"user_id":"","sort_type":2,"cursor":"10"}
header字段content-typecookie
query_list字段user_idsort_typecursor
response
data =
{"err_no":0,"err_msg":"success","data":[{"article_id":"6921509748785283086","article_info":{"article_id":"6921509748785283086","user_id":"xxx","category_id":"xxxx","tag_ids":[6809640407484334093,6809640398105870343],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"这些一行 JS 实现功能的代码,让你看起来像一个前端专家","brief_content":"从复杂的框架到处理 API,有太多的东西需要学习。 但是,它也能让你只用一行代码就能做一些了不起的事情。 1. 获取一个随机布尔值 (true/false) 这个函数使用 Math.random() 方法返回一个布尔值(true 或 false)。Math.random 将在 …","is_english":0,"is_original":1,"user_index":0,"original_type":0,"original_author":"","content":"","ctime":"1611539616","mtime":"1611551516","rtime":"1611540252","draft_id":"6921317674265870350","view_count":32454,"collect_count":1048,"digg_count":871,"comment_count":103,"hot_index":2596,"is_hot":0,"rank_index":0.04573958,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798},{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192}],"user_interact":{"id":6921509748785283086,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6919295789630455815","article_info":{"article_id":"6919295789630455815","user_id":"xxx","category_id":"xxx","tag_ids":[6809640407484334093,6809640398105870343],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"前端搞工程化:从零打造性能检测库「源码 + 视频」","brief_content":"聊下来以后得出一些结论:这类读者普遍就职于中小型公司,前端人员个位数,平时疲于开发,团队内部几乎没有基础建设,工具很蛮荒。工程化对于这些读者来说很陌生,基本不知道这到底是什么,或者说认为 Webpack 就是前端工程化的全部了。 笔者目前就职于某厂的基础架构组,为百来号前端提供…","is_english":0,"is_original":1,"user_index":0,"original_type":0,"original_author":"","content":"","ctime":"1611024111","mtime":"1611053569","rtime":"1611053079","draft_id":"6919294191281373198","view_count":21679,"collect_count":661,"digg_count":706,"comment_count":41,"hot_index":1830,"is_hot":0,"rank_index":0.03106026,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798},{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192}],"user_interact":{"id":6919295789630455815,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6912307309574094855","article_info":{"article_id":"6912307309574094855","user_id":"xxxx","category_id":"xxx","tag_ids":[6809640407484334093,6809640398105870343],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"时代变了,来看看你用的那些前端技术已经过时了","brief_content":"首先技术过时是看你当前业务的场景的。比如说有些东西是需要用在 IE6 上的,那对于大部分人开发者来说它就是一个过时的技术,但是如果你的业务还需要服务到 IE6 的用户,那么这个技术对你就还是存在价值的。 今天我们聊得过时技术只针对于大部分人,先来聊聊性能优化中已经过时的东西。 …","is_english":0,"is_original":1,"user_index":0,"original_type":0,"original_author":"","content":"","ctime":"1609396977","mtime":"1609405903","rtime":"1609396979","draft_id":"6912307150454784014","view_count":9792,"collect_count":18,"digg_count":70,"comment_count":42,"hot_index":601,"is_hot":0,"rank_index":0.0090178,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798},{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192}],"user_interact":{"id":6912307309574094855,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6893435960705417224","article_info":{"article_id":"6893435960705417224","user_id":"xxx","category_id":"xxx","tag_ids":[6809640407484334093,6809640398105870343],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"前端搞算法再也不难,如何套路解题:滑动窗口类","brief_content":"这不是一个给一道题目然后告诉你题解的系列,而是对于一系列题目进行分类,找出他们解题规律并得出大致框架代码的文章。吃透解一系列题目的规律比会解单个题目有用的多,毕竟你总会遇到没刷过的题。 大家对于滑动窗口应该不陌生,在 TCP 协议中就有这个概念的出现,用于控制网络流量,避免拥塞…","is_english":0,"is_original":1,"user_index":16.17291061766203,"original_type":0,"original_author":"","content":"","ctime":"1605003324","mtime":"1605003377","rtime":"1605003377","draft_id":"6893432059353235470","view_count":5148,"collect_count":118,"digg_count":104,"comment_count":11,"hot_index":372,"is_hot":0,"rank_index":0.00441318,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798},{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192}],"user_interact":{"id":6893435960705417224,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6889231003697709070","article_info":{"article_id":"6889231003697709070","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"前端前沿观察,Cookie 居然可以这样整了","brief_content":"用 JS 操作 Cookie 其实是很麻烦的,并不存在一个简单的 API 能让我们获取或者设置 Cookie。 唯一一个操作 Cookie 的 API 是 document.cookie,但是这句代码使用起来很难受。如果说我们想要获取一个需要的 Cookie,可能得先写这么一个…","is_english":0,"is_original":1,"user_index":0,"original_type":0,"original_author":"","content":"","ctime":"1604024158","mtime":"1604044402","rtime":"1604024161","draft_id":"6889199221539340301","view_count":17839,"collect_count":220,"digg_count":275,"comment_count":47,"hot_index":1213,"is_hot":0,"rank_index":0.01306296,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6889231003697709070,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6869573288478113799","article_info":{"article_id":"6869573288478113799","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"","cover_image":"","is_gfw":0,"title":"Promise 你真的用明白了么?","brief_content":"文章首发自笔者的 Github。 Promise 关于 API 这块大家应该都能熟练使用,但是和微任务相关的你可能还存在知识盲区。 在开始正文前,我们先把本文涉及到的一些内容提前定个基调。 Promise 中只有涉及到状态变更后才需要被执行的回调才算是微任务,比如说 then、…","is_english":0,"is_original":1,"user_index":0,"original_type":0,"original_author":"","content":"","ctime":"1599447185","mtime":"1599532093","rtime":"1599447392","draft_id":"6869381749596651533","view_count":18078,"collect_count":417,"digg_count":349,"comment_count":68,"hot_index":1320,"is_hot":0,"rank_index":0.01132008,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6869573288478113799,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6850037270729359367","article_info":{"article_id":"6850037270729359367","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"https://juejin.im/post/6850037270729359367","cover_image":"","is_gfw":0,"title":"还在看那些老掉牙的性能优化文章么?这些最新性能指标了解下","brief_content":"性能优化相关的文章其实网上挺多,但是大部分都是在讲如何优化性能,也就是讲方法论。但是在实际工作中,如何量化性能优化也是相当重要的一环。今天本文会介绍谷歌提倡的七个用户体验指标(也可以认为是性能指标),每个指标分别根据以下几点讲解: 首次绘制,FP(First Paint),这个…","is_english":0,"is_original":1,"user_index":16.541048162157,"original_type":0,"original_author":"","content":"","ctime":"1594697857","mtime":"1599053141","rtime":"1594697857","draft_id":"6850424871835402248","view_count":23897,"collect_count":803,"digg_count":622,"comment_count":27,"hot_index":1843,"is_hot":0,"rank_index":0.01303951,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6850037270729359367,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6844904201672196110","article_info":{"article_id":"6844904201672196110","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"https://juejin.im/post/6844904201672196110","cover_image":"","is_gfw":0,"title":"总感觉自己不会的太多了,不知该如何下手?","brief_content":"前端东西确实蛮多,但也没必要什么都想学。一旦你有这个想法,多半会像个无头苍蝇乱飞。这个看看,那个学点,到头来啥东西都没学好。 这样的例子其实我在读者里看到好些了,学习确实看起来是在学习,啥资料都收藏了,今天看会这个技术的视频,明天拿上另一个技术的书读起来,但是这种学习方式相当低…","is_english":0,"is_original":1,"user_index":0.53262452509886,"original_type":0,"original_author":"","content":"","ctime":"1593400023","mtime":"1599038787","rtime":"1593400023","draft_id":"6845076841087107080","view_count":14092,"collect_count":124,"digg_count":229,"comment_count":48,"hot_index":981,"is_hot":0,"rank_index":0.00654788,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6844904201672196110,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6844904079257239560","article_info":{"article_id":"6844904079257239560","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"https://juejin.im/post/6844904079257239560","cover_image":"","is_gfw":0,"title":"Hooks 的性能优化及可能会遇到的坑总结","brief_content":"class 组件中性能优化可以通过 shouldComponentUpdate 实现或者继承自 PureComponent,当然后者也是通过 shouldComponentUpdate 去做的,内部对 state 和 props 进行了 shallowEqual。 对于函数组件…","is_english":0,"is_original":1,"user_index":4.247329774891,"original_type":0,"original_author":"","content":"","ctime":"1583115833","mtime":"1598550910","rtime":"1583115833","draft_id":"6845076655619211278","view_count":6938,"collect_count":65,"digg_count":74,"comment_count":9,"hot_index":429,"is_hot":0,"rank_index":0.00205873,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6844904079257239560,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"},{"article_id":"6844904042171203591","article_info":{"article_id":"6844904042171203591","user_id":"xxx","category_id":"xxx","tag_ids":[6809640398105870343,6809640407484334093],"visible_level":0,"link_url":"https://juejin.im/post/6844904042171203591","cover_image":"","is_gfw":0,"title":"一句话讲明白 WebAssembly、微前端等技术背后的核心","brief_content":"WebAssembly 是在浏览器端可执行的字节码,主要解决的问题是性能。编辑器能把 C、C++、Go、TS 等语言编译成 WebAssembly 并能在浏览器中运行。 使用场景一般就是对性能有很高要求的应用,另外也可以把一些本来需要在后端完成的操作放到前端来做。比如视频解码、…","is_english":0,"is_original":1,"user_index":16.456998401581,"original_type":0,"original_author":"","content":"","ctime":"1578624067","mtime":"1598543145","rtime":"1578624067","draft_id":"xxx","view_count":6186,"collect_count":59,"digg_count":107,"comment_count":24,"hot_index":440,"is_hot":0,"rank_index":0.00191574,"status":2,"verify_status":1,"audit_status":2,"mark_content":""},"author_user_info":{"user_id":"xxx","user_name":"yck","company":"「前端真好玩」公众号作者","job_title":"前端开发","avatar_large":"https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/a386aa8db73c9678458ec34161472ca5~300x300.image","level":7,"description":"","followee_count":21,"follower_count":34239,"post_article_count":82,"digg_article_count":103,"got_digg_count":44102,"got_view_count":1424658,"post_shortmsg_count":11,"digg_shortmsg_count":7,"isfollowed":false,"favorable_author":1,"power":58150,"study_point":0,"university":{"university_id":"0","name":"","logo":""},"major":{"major_id":"0","parent_id":"0","name":""},"student_status":0,"select_event_count":0,"select_online_course_count":0,"identity":0,"is_select_annual":false,"select_annual_rank":98,"annual_list_type":0,"extraMap":{},"is_logout":0},"category":{"category_id":"xxx","category_name":"前端","category_url":"frontend","rank":2,"ctime":1457483942,"mtime":1432503190,"show_type":3,"item_type":2},"tags":[{"id":2546519,"tag_id":"6809640398105870343","tag_name":"JavaScript","color":"#616161","icon":"https://lc-gold-cdn.xitu.io/5d70fd6af940df373834.png","back_ground":"","show_navi":0,"ctime":1435884803,"mtime":1627887191,"id_type":9,"tag_alias":"","post_article_count":62713,"concern_user_count":398192},{"id":2546526,"tag_id":"6809640407484334093","tag_name":"前端","color":"#60ADFF","icon":"https://lc-gold-cdn.xitu.io/bac28828a49181c34110.png","back_ground":"","show_navi":1,"ctime":1435971546,"mtime":1627887045,"id_type":9,"tag_alias":"","post_article_count":74716,"concern_user_count":526798}],"user_interact":{"id":6844904042171203591,"omitempty":2,"user_id":0,"is_digg":false,"is_follow":false,"is_collect":false},"org":{"org_info":null,"org_user":null,"is_followed":false},"req_id":"server req_id test"}],"cursor":"20","count":82,"has_more":true}
- 文章爬取
import csv
import re
import time
from json import dumps
import requests
class JueJin(object):
headers = {
}
def __init__(self):
self.res_list = []
def get_url_list(self):
# 文章列表页
url = "https://api.juejin.cn/content_api/v1/article/query_list"
detail_url = "https://juejin.cn/post/"
del_list = []
for item in [80]:
data = {"user_id": "", "sort_type": 2, "cursor": str(item)}
try:
response = requests.post(url=url, headers=self.headers, data=dumps(data).encode("utf-8"))
except Exception:
break
return False, '服务器网络故障'
if response.status_code != 200:
break
return False, '来源服务器错误'
a = response.content.decode('utf8')
strinfo = re.compile('false')
a = strinfo.sub('False', a)
strinfo = re.compile('true')
a = strinfo.sub('True', a)
strinfo = re.compile('null')
a = strinfo.sub('None', a)
a = eval(a) # 将数据转成dict格式
data = a.get('data')
if data == []: # 列表为空时,跳出循环
break
else:
DayTime = time.strftime('%Y-%m-%d', time.localtime(time.time())) # 一天一存
for item in data:
url = item.get('article_id')
article_id = item.get('article_id')
title = item.get('article_info').get('title')
detail = item.get('article_info').get('brief_content')
ctime = item.get('article_info').get('ctime')
del_list.append({'url': detail_url + url, 'title': title, 'detail': detail, 'ctime': ctime,
'article_id': article_id})
with open(f'{DayTime}-4.csv', 'a+', newline='') as csvfile:
# ID 标题 时间 简介 正文
writer = csv.writer(csvfile)
timeArray = time.localtime(int(ctime))
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
data = (detail_url+str(url), title, detail, otherStyleTime)
writer.writerow(data)
return del_list
def detail_data(self, del_list):
# 文章详情页
for index, item in enumerate(del_list):
url = 'https://api.juejin.cn/content_api/v1/article/detail'
data = {'article_id': item.get('article_id')}
response = requests.post(url=url, headers=self.headers, data=dumps(data).encode("utf-8"))
a = response.content.decode('utf8')
strinfo = re.compile('false')
a = strinfo.sub('False', a)
strinfo = re.compile('true')
a = strinfo.sub('True', a)
strinfo = re.compile('null')
a = strinfo.sub('None', a)
a = eval(a) # 将数据转成dict格式
if a.get('data').get('article_info').get('content'):
content = a.get('data').get('article_info').get('content')
else:
content = a.get('data').get('article_info').get('mark_content')
content = repr(content).replace('\u', '')
self.res_list[index].update(
content=content
)
# with open('20210803.csv', 'a+', newline='') as csvfile:
# writer = csv.writer(csvfile)
# data = (item.get('title'), item.get("detail"), str(content), item.get("url"), item.get("ctime"))
# writer.writerow(data)
time.sleep(1)
Obj = JueJin()
del_list = Obj.get_url_list()
Obj.detail_data(del_list)
# print(len(Obj.res_list), Obj.res_list)
- 关键词分析