support clients of ten websites

This commit is contained in:
CharlesPikachu
2022-03-11 15:21:08 +08:00
parent b55b13f0fe
commit 2f6d8363ad
13 changed files with 302 additions and 1 deletions
+3
View File
@@ -45,6 +45,9 @@ class Client():
'QQQun': QQQunClient, 'zhihu': ZhihuClient, 'taobao': TaobaoClient, 'toutiao': ToutiaoClient,
'jingdong': JingdongClient, 'ifeng': IfengClient, 'sohu': SohuClient, 'zgconline': ZgconlineClient,
'twitter': TwitterClient, 'renren': RenRenClient, 'lagou': LagouClient, 'eSurfing': eSurfingClient,
'w3cschool': W3CSchoolClient, 'fishc': FishCClient, 'youdao': YoudaoClient, 'stackoverflow': StackoverflowClient,
'baidupan': BaiduPanClient, 'douyu': DouyuClient, 'codalab': CodaLabClient, 'pypi': PyPiClient,
'migu': MiguClient, 'qunar': QunarClient,
}
for key, value in self.supported_clients.items():
setattr(self, key, value)
+11 -1
View File
@@ -1,16 +1,23 @@
'''initialize'''
from .migu import MiguClient
from .pypi import PyPiClient
from .sohu import SohuClient
from .QQId import QQIdClient
from .qunar import QunarClient
from .fishc import FishCClient
from .lagou import LagouClient
from .ifeng import IfengClient
from .zhihu import ZhihuClient
from .QQQun import QQQunClient
from .weibo import WeiboClient
from .douyu import DouyuClient
from .youdao import YoudaoClient
from .renren import RenRenClient
from .taobao import TaobaoClient
from .github import GithubClient
from .douban import DoubanClient
from .QQZone import QQZoneClient
from .codalab import CodaLabClient
from .toutiao import ToutiaoClient
from .twitter import TwitterClient
from .zt12306 import Zt12306Client
@@ -18,4 +25,7 @@ from .eSurfing import eSurfingClient
from .music163 import Music163Client
from .bilibili import BiliBiliClient
from .jingdong import JingdongClient
from .zgconline import ZgconlineClient
from .baidupan import BaiduPanClient
from .zgconline import ZgconlineClient
from .w3cschool import W3CSchoolClient
from .stackoverflow import StackoverflowClient
+24
View File
@@ -0,0 +1,24 @@
'''
Function:
百度网盘客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
from .baseclient import BaseClient
'''百度网盘客户端'''
class BaiduPanClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(BaiduPanClient, self).__init__(website_name='baidupan', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://www.baidu.com/'
response = session.get(url)
if 'username' in response.text:
return False
return True
+24
View File
@@ -0,0 +1,24 @@
'''
Function:
CodaLab客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
from .baseclient import BaseClient
'''CodaLab客户端'''
class CodaLabClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(CodaLabClient, self).__init__(website_name='codalab', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://competitions.codalab.org/'
response = session.get(url)
if infos_return['username'] in response.text:
return False
return True
+26
View File
@@ -0,0 +1,26 @@
'''
Function:
斗鱼客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
import re
from .baseclient import BaseClient
'''斗鱼客户端'''
class DouyuClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(DouyuClient, self).__init__(website_name='douyu', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://www.douyu.com/member'
response = session.get(url)
username = re.findall(r'uname_con clearfix" title="(.*?)"', response.text)[0]
if infos_return['username'] == username:
return False
return True
+26
View File
@@ -0,0 +1,26 @@
'''
Function:
鱼C论坛客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
import re
from .baseclient import BaseClient
'''鱼C论坛客户端'''
class FishCClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(FishCClient, self).__init__(website_name='fishc', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://fishc.com.cn/'
response = session.get(url)
nickname = re.findall(r'title="访问我的空间">(.*?)</a>', response.text)[0]
if infos_return['nickname'] == nickname:
return False
return True
+34
View File
@@ -0,0 +1,34 @@
'''
Function:
咪咕客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
import requests
from .baseclient import BaseClient
'''咪咕客户端'''
class MiguClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(MiguClient, self).__init__(website_name='migu', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
cookies = requests.utils.dict_from_cookiejar(session.cookies)
cookies_str = []
for key in cookies.keys():
cookies_str.append(f'{key}={cookies[key]}')
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36',
'referer': 'https://music.migu.cn/v3/my',
'cookie': '; '.join(cookies_str),
}
url = 'https://music.migu.cn/v3/api/my/listen/listend?page=1'
response = session.get(url, headers=headers)
if '成功' in response.text:
return False
return True
+24
View File
@@ -0,0 +1,24 @@
'''
Function:
PyPi客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
from .baseclient import BaseClient
'''PyPi客户端'''
class PyPiClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(PyPiClient, self).__init__(website_name='pypi', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://pypi.org/_includes/current-user-indicator/'
response = session.get(url)
if infos_return['username'] in response.text:
return False
return True
+24
View File
@@ -0,0 +1,24 @@
'''
Function:
去哪儿旅行客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
from .baseclient import BaseClient
'''去哪儿旅行客户端'''
class QunarClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(QunarClient, self).__init__(website_name='qunar', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://user.qunar.com/webApi/getPwdType.jsp'
response = session.post(url)
if 'success' in response.text:
return False
return True
@@ -0,0 +1,26 @@
'''
Function:
Stackoverflow客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
import re
from .baseclient import BaseClient
'''Stackoverflow客户端'''
class StackoverflowClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(StackoverflowClient, self).__init__(website_name='stackoverflow', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://stackoverflow.com/'
response = session.get(url)
profile_url = 'https://stackoverflow.com' + re.findall(r'<a href="(.+)" class="my-profile', response.text)[0]
if infos_return['profile_url'] == profile_url:
return False
return True
+41
View File
@@ -0,0 +1,41 @@
'''
Function:
W3CSchool客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
import requests
from .baseclient import BaseClient
'''W3CSchool客户端'''
class W3CSchoolClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(W3CSchoolClient, self).__init__(website_name='w3cschool', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'https://www.w3cschool.cn/index/checkHeader'
cookies = requests.utils.dict_from_cookiejar(session.cookies)
cookies_str = []
for key in ['PHPSESSID', 'ypre_saltkey', 'ypre_auth', 'ypre_sauth', 'ypre_uid']:
cookies_str.append(f'{key}={cookies[key]}')
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36',
'Host': 'www.w3cschool.cn',
'Origin': 'https://www.w3cschool.cn',
'Referer': 'https://www.w3cschool.cn/my',
'X-Requested-With': 'XMLHttpRequest',
'Cookie': '; '.join(cookies_str),
}
data = {
'headerType': '0',
'_hash': session.cookies.get('ypre_saltkey'),
}
response = session.post(url, headers=headers, data=data)
if response.json()['statusCode'] == 200:
return False
return True
+30
View File
@@ -0,0 +1,30 @@
'''
Function:
有道客户端
Author:
Charles
微信公众号:
Charles的皮卡丘
更新日期:
2022-03-11
'''
from .baseclient import BaseClient
'''有道客户端'''
class YoudaoClient(BaseClient):
def __init__(self, reload_history=True, **kwargs):
super(YoudaoClient, self).__init__(website_name='youdao', reload_history=reload_history, **kwargs)
'''检查会话是否已经过期, 过期返回True'''
def checksessionstatus(self, session, infos_return):
url = 'http://dict.youdao.com/login/acc/query/accountinfo'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36',
'Host': 'dict.youdao.com',
'Referer': 'http://dict.youdao.com/wordbook/wordlist?keyfrom=dict2.index'
}
response = session.get(url, headers=headers)
response_json = response.json()
if response_json['msg'] == 'OK' and response_json['code'] == 0:
return False
return True
+9
View File
@@ -751,6 +751,13 @@ class miguPC():
response_json = response.json()
# 登录成功
if response_json['status'] == 2000:
params = {
'callbackURL': 'https://music.migu.cn/v3',
'relayState': '',
'token': response_json['result']['token'],
}
response = self.session.get(self.check_url, params=params)
response = self.session.get(self.home_url)
print('[INFO]: Account -> %s, login successfully' % username)
infos_return = {'username': username}
infos_return.update(response_json)
@@ -769,6 +776,8 @@ class miguPC():
}
self.publickey_url = 'https://passport.migu.cn/password/publickey'
self.login_url = 'https://passport.migu.cn/authn'
self.check_url = 'https://music.migu.cn/v3/user/login?'
self.home_url = 'https://music.migu.cn/v3'
self.session.headers.update(self.headers)