Example #1
0
def set_cookie():
    if os.path.isfile('cookie'):
        print('cookie 已存在')
    else:
        print('由于 Terminal 本身对输入内容长度的限制')
        cookie_content1 = input('请先输入 cookie 的前一半\n>  ')
        cookie_content2 = input('请继续输入 cookie 的后一半\n>  ')
        cookie_content = cookie_content1 + cookie_content2
        with open('cookie', 'w') as f:
            f.write(cookie_content)
        print('cookie 已保存')

    with open('cookie') as f:
        api.cookie(f.read())
    print('cookie 已配置完成')
Example #2
0
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipreacher'

import zhihuapi as api

with open('cookie') as f:
    api.cookie(f.read())

r1 = []
r2 = []
r5 = []


# 拉取关注者的昵称和个性域名,page 根据自己关注者页数确定
def followers(me, page):
    for i in range(page):
        data = api.user(me).followers(offset=(20 * i))
        for j in range(len(data)):
            r1.append(data[j]['name'])  # 关注者的昵称
            r2.append(data[j]['url_token'])  # 关注者的个性域名


# 分行打印关注者的昵称和个性域名
def show(r):
    for k in range(len(r1)):
        s = (r[k] + '\n')
        print(s)