import requests
import json
import pprint
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0',
'cookie':'MLOGIN=1; ***'
}
url ='https://m.weibo.cn/feed/friends'
def get_info(url, page):
print(url)
res = requests.get(url,headers=headers)
json_data = json.loads(res.text)
# pprint.pprint(json_data)
? ? statuses = json_data['data']['statuses']
for statusein statuses:
name = statuse['user']['screen_name']
phone = statuse['source']
print("昵稱: " + name +'\t\t\t' +"終端: " + phone)
max_id = json_data['data']['next_cursor']
page +=1
? ? if page <=20:
next_url ='https://m.weibo.cn/feed/friends?max_id={}'.format(max_id)
get_info(next_url, page)
if __name__ =='__main__':
get_info(url,1)