Bump redis from 3.5.3 to 4.5.3 #6
1
.gitignore
vendored
1
.gitignore
vendored
@ -140,4 +140,3 @@ test.py
|
||||
.DS_Store
|
||||
.idea/.name
|
||||
.idea/workspace.xml
|
||||
.vscode/settings.json
|
||||
|
97
Pixiv.py
97
Pixiv.py
@ -1,21 +1,12 @@
|
||||
"""
|
||||
P站小爬虫 爬每日排行榜
|
||||
环境需求:Python3.6+ / Redis
|
||||
环境需求:Python3.6+ / Redis
|
||||
项目地址:https://github.com/nyaasuki/PixivSpider
|
||||
支持 M1 芯片
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
载 入 区 域
|
||||
--------------------------------------------------------------
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
import os
|
||||
from cmd import Cmd
|
||||
|
||||
try:
|
||||
import requests
|
||||
@ -31,15 +22,7 @@ requests.packages.urllib3.disable_warnings()
|
||||
error_list = []
|
||||
|
||||
|
||||
"""
|
||||
|
||||
V 1 . 0 祖 传 代 码 区 域
|
||||
---------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
|
||||
|
||||
class PixivSpider(Cmd):
|
||||
class PixivSpider(object):
|
||||
|
||||
def __init__(self):
|
||||
self.ajax_url = 'https://www.pixiv.net/ajax/illust/{}/pages' # id
|
||||
@ -125,32 +108,12 @@ class PixivSpider(Cmd):
|
||||
cls.data = data
|
||||
|
||||
@classmethod
|
||||
def pixiv_main(cls):
|
||||
print('开始抓取...')
|
||||
for i in range(1, 11, 1): # p站每日排行榜最多为500个
|
||||
pixiv.get_top_url(i)
|
||||
for j in pixiv.get_top_pic():
|
||||
k = pixiv.get_list(j) # 接口暂时不想写了 先这样凑合一下吧
|
||||
if k:
|
||||
error_list.append(k)
|
||||
for k in error_list:
|
||||
pixiv.r.delete(k)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
C M D 循 环 区 域
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def main(self):
|
||||
def pixiv_main(cls):
|
||||
cookie = pixiv.r.get('cookie')
|
||||
if not cookie:
|
||||
cookie = input('[Pixiv] 请输入一个cookie:')
|
||||
cookie = input('请输入一个cookie:')
|
||||
pixiv.r.set('cookie', cookie)
|
||||
self.headers = {
|
||||
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',
|
||||
@ -160,49 +123,19 @@ class PixivSpider(Cmd):
|
||||
'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):
|
||||
print('[Help] rank - 爬取 Pixiv每日排行榜前500的插画')
|
||||
print('[Help] stars - 爬取 你已经添加❤的插画 *需要用户cookie*')
|
||||
print('[Help] like - 爬取 每日推荐插画 *需要用户cookie*')
|
||||
print('[Help] cookie - 更换已保存的cookie')
|
||||
print('[Help] quit - 退出程序')
|
||||
|
||||
|
||||
def do_quit(self):
|
||||
exit()
|
||||
|
||||
def do_rank(self):
|
||||
self.pixiv_main()
|
||||
|
||||
def do_stars(self):
|
||||
pass
|
||||
|
||||
def do_like(self):
|
||||
pass
|
||||
|
||||
def do_cookie(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
||||
启 动 区 域
|
||||
----------------------------------------------------------
|
||||
|
||||
"""
|
||||
|
||||
print('开始抓取...')
|
||||
for i in range(1, 11, 1): # p站每日排行榜最多为500个
|
||||
pixiv.get_top_url(i)
|
||||
for j in pixiv.get_top_pic():
|
||||
k = pixiv.get_list(j) # 接口暂时不想写了 先这样凑合一下吧
|
||||
if k:
|
||||
error_list.append(k)
|
||||
for k in error_list:
|
||||
pixiv.r.delete(k)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pixiv = PixivSpider()
|
||||
pixiv.main()
|
||||
pixiv.pixiv_main()
|
||||
# for id_url in pixiv.get_list():
|
||||
# pixiv.get_img(id_url)
|
||||
|
@ -44,11 +44,7 @@ ERROR: No matching distribution found for resquests`
|
||||
|
||||
此项储存在本地redis中
|
||||
|
||||
3.复位程序
|
||||
|
||||
请清除Redis中的数据,更换cookie同理
|
||||
|
||||
## 特别提醒
|
||||
|
||||
正常来说,当没有出现上方问题时,程序出现问题大多为你的上网方式不够科学
|
||||
缓慢更新中...
|
||||
缓慢更新中...
|
||||
|
@ -1,2 +1,2 @@
|
||||
redis==3.5.3
|
||||
requests==2.25.1
|
||||
requests==2.22.0
|
Loading…
Reference in New Issue
Block a user