From 0f59d18202c72dd6ac5b5502ed06550b9596593a Mon Sep 17 00:00:00 2001 From: nyaasuki Date: Fri, 14 May 2021 21:45:34 +0800 Subject: [PATCH 1/6] update dev --- Pixiv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pixiv.py b/Pixiv.py index 72ad5fc..032b7d0 100644 --- a/Pixiv.py +++ b/Pixiv.py @@ -1,7 +1,8 @@ """ P站小爬虫 爬每日排行榜 -环境需求:Python3.6+ / Redis +环境需求:Python3.6+ / Redis 项目地址:https://github.com/nyaasuki/PixivSpider +支持 M1 芯片 """ From 4313e9d7743c42682e23f4116f9ed3e1bb592c93 Mon Sep 17 00:00:00 2001 From: nyaasuki Date: Fri, 14 May 2021 22:06:32 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83afe8d..f2dab3a 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,11 @@ ERROR: No matching distribution found for resquests` 此项储存在本地redis中 +3.复位程序 + +请清除Redis中的数据,更换cookie同理 + ## 特别提醒 正常来说,当没有出现上方问题时,程序出现问题大多为你的上网方式不够科学 -缓慢更新中... +缓慢更新中... \ No newline at end of file From ffd636c87019307b7692f7cbe227326c74828b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=9B=E9=A3=8E?= Date: Mon, 17 May 2021 01:58:51 +0000 Subject: [PATCH 3/6] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d6f5551..b4b973b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ redis==3.5.3 -requests==2.22.0 \ No newline at end of file +requests==2.25.1 From 440ab1ab06feb11e464a81dffd4aa13605fb5f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=9B=E9=A3=8E?= Date: Mon, 17 May 2021 16:39:08 +0800 Subject: [PATCH 4/6] up to date --- Pixiv.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/Pixiv.py b/Pixiv.py index 032b7d0..dba0a5d 100644 --- a/Pixiv.py +++ b/Pixiv.py @@ -6,8 +6,16 @@ P站小爬虫 爬每日排行榜 """ +""" + + 载 入 区 域 +-------------------------------------------------------------- + +""" + import re import os +from cmd import Cmd try: import requests @@ -23,7 +31,15 @@ requests.packages.urllib3.disable_warnings() error_list = [] -class PixivSpider(object): +""" + + V 1 . 0 祖 传 代 码 区 域 +--------------------------------------------------------------------- + +""" + + +class PixivSpider(Cmd): def __init__(self): self.ajax_url = 'https://www.pixiv.net/ajax/illust/{}/pages' # id @@ -133,10 +149,47 @@ class PixivSpider(object): error_list.append(k) for k in error_list: pixiv.r.delete(k) + + +""" + + C M D 循 环 区 域 +--------------------------------------------------------------------------------- + +""" + + + def main(self): + self.cmdloop() + + def do_help(self): + pass + + def do_exit(self): + pass + + def do_rank(self): + pass + + def do_stars(self): + pass + + def do_like(self): + pass + + + +""" + + 启 动 区 域 +---------------------------------------------------------- + +""" + if __name__ == '__main__': pixiv = PixivSpider() - pixiv.pixiv_main() + pixiv.main() # for id_url in pixiv.get_list(): # pixiv.get_img(id_url) From 877a26f2bf3fe66ff572a9e02563f35daf461ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=9B=E9=A3=8E?= Date: Mon, 17 May 2021 16:39:28 +0800 Subject: [PATCH 5/6] up to date --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 20ab3b5..4bca4a4 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,4 @@ test.py .DS_Store .idea/.name .idea/workspace.xml +.vscode/settings.json From 1bc7fd78ee2dc448b64cb78ba742ebf00830fb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B2=9B=E9=A3=8E?= Date: Mon, 17 May 2021 17:03:09 +0800 Subject: [PATCH 6/6] up to date --- Pixiv.py | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/Pixiv.py b/Pixiv.py index dba0a5d..bb63a39 100644 --- a/Pixiv.py +++ b/Pixiv.py @@ -125,21 +125,7 @@ class PixivSpider(Cmd): cls.data = data @classmethod - def pixiv_main(cls): - cookie = pixiv.r.get('cookie') - if not cookie: - cookie = input('请输入一个cookie:') - pixiv.r.set('cookie', cookie) - cls.headers = { - 'accept': 'application/json', - 'accept-language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6', - 'dnt': '1', - 'cookie': f'{cookie}', - 'referer': 'https://www.pixiv.net/', - 'sec-fetch-mode': 'cors', - 'sec-fetch-site': 'same-origin', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36' - } + def pixiv_main(cls): print('开始抓取...') for i in range(1, 11, 1): # p站每日排行榜最多为500个 pixiv.get_top_url(i) @@ -153,23 +139,47 @@ class PixivSpider(Cmd): """ - C M D 循 环 区 域 + C M D 循 环 区 域 --------------------------------------------------------------------------------- """ def main(self): + cookie = pixiv.r.get('cookie') + if not cookie: + cookie = input('[Pixiv] 请输入一个cookie:') + pixiv.r.set('cookie', cookie) + self.headers = { + 'accept': 'application/json', + 'accept-language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6', + 'dnt': '1', + 'cookie': f'{cookie}', + 'referer': 'https://www.pixiv.net/', + 'sec-fetch-mode': 'cors', + 'sec-fetch-site': 'same-origin', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36' + } + if cookie == () : + print('[Redis] 未输入cookie,部分功能受限') + else + print(f'[Redis] 成功储存Cookie:{cookie}') + self.cmdloop() def do_help(self): - pass + print('[Help] rank - 爬取 Pixiv每日排行榜前500的插画') + print('[Help] stars - 爬取 你已经添加❤的插画 *需要用户cookie*') + print('[Help] like - 爬取 每日推荐插画 *需要用户cookie*') + print('[Help] cookie - 更换已保存的cookie') + print('[Help] quit - 退出程序') - def do_exit(self): - pass + + def do_quit(self): + exit() def do_rank(self): - pass + self.pixiv_main() def do_stars(self): pass @@ -177,6 +187,9 @@ class PixivSpider(Cmd): def do_like(self): pass + def do_cookie(self): + pass + """