本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途,如侵立删! |
记一次阿里云盾滑块验证分析并通过
操作环境
数据接口
https://**********?containerid=100103type%3D{chanenl}%26q%3D{quote(self.words)}&page_type=searchall&page={page}
https://**********?title=%E5%9F%BA%E6%9C%AC%E8%B5%84%E6%96%99&value={userid}'
proxy配置
使用socks需安装 :pip install -U ‘requests[socks]’
def _proxy(self):
"""
调用
:return:
"""
new_time = datetime.datetime.now()
if self.expire_time and new_time < datetime.datetime.strptime(self.expire_time, "%Y-%m-%d %H:%M:%S"):
print(f'当前使用IP:{self.proxies} 过期时间:{self.expire_time}')
return
proxy = Proxy()
ip_port, expire_time = proxy.main()
self.headers = proxy.headers
self.proxies = {
'http': 'socks5://{}'.format(ip_port),
'https': 'socks5://{}'.format(ip_port)
}
self.expire_time = expire_time
根据关键词获取userid
def _get_userid(self, response):
userid = []
content = json.loads(response)
cards = content['data']['cards']
for card in cards:
if card['card_type'] != 11:
continue
for card_group in card['card_group']:
userid.append(card_group['user']['id'])
return userid
根据userid获取信息
def _parse_json(self, res):
content = json.loads(res)
data = {}
data['用户id'] = content['data']['userInfo']['id']
data['用户名'] = content['data']['userInfo']['screen_name']
sex = content['data']['userInfo']['gender']
data['性别'] = '女' if sex == 'f' else '男'
data['微博认证名称'] = content['data']['userInfo']['verified_reason']
data['简介'] = content['data']['userInfo']['description']
data['粉丝数量'] = content['data']['userInfo']['followers_count']
data['发布微博量'] = content['data']['userInfo']['statuses_count']
data['关注量'] = content['data']['userInfo']['follow_count']
data['用户头像'] = content['data']['userInfo']['profile_image_url']
data['移动端地址'] = content['data']['userInfo']['profile_url']
data['关键词'] = self.words
return data
数据保存
def _save_xls(self, data):
"""
保存数据
data : 字典格式 必须和表头长度一样
:return:
"""
file = f'{PATH}/数据/关键词-{self.words}.xlsx'
Header = ['用户id', '用户名', '性别', '微博认证名称', '简介', '粉丝数量', '发布微博量', '关注量', '用户头像', '移动端地址', '关键词']
if not os.path.exists(f'{PATH}/数据'):
os.mkdir(f'{PATH}/数据')
if not os.path.exists(file):
df = pd.DataFrame(columns=Header)
else:
df_read = pd.read_excel(file)
df = pd.DataFrame(df_read)
new_data = pd.DataFrame(data, index=[1])
df = df.append(new_data, ignore_index=True)
df.to_excel(file, sheet_name=self.words, index=False, header=True)
数据:
打开App,阅读手记