Python2.7获取QQ空间部分好友
来源:互联网 发布:jquery ui.min.js 1.8 编辑:程序博客网 时间:2024/05/17 14:25
首先需要安装curl工具,然后复制curl
参考http://blog.csdn.net/gsls200808/article/details/46933307
浏览器打开http://user.qzone.qq.com/[QQ号码]/myhome/friends,复制friend_ship_manager.cgi为curl
获取的是我在意谁和谁在意我的json列表,QQ空间对我在意谁的好友数目限制是200,谁在意我的好友数目限制是200,代码把两个列表全部获取了,但是通过这个方法有个缺陷,当好友数大于200时,无法获取完整的好友列表
代码如下
# -*- coding: UTF-8 -*-import osimport shleximport subprocessimport json# 添加curl的环境变量os.putenv('PATH', 'D:\\curl-7.33.0-win64-nossl\\;' + os.getenv('PATH'))# 浏览器打开http://user.qzone.qq.com/[QQ号码]/myhome/friends,复制friend_ship_manager.cgi为curl# 我在意谁do=1,谁在意我do=2origin_friend = 'friend_ship_manager.cgi'origin_friend = origin_friend.replace('--compressed ', '')curl = origin_friendargs = shlex.split(curl)result = subprocess.check_output(args).decode('utf-8')jsonstr = result[result.find('(') + 1: result.find(')', -1) - 1] # json字符串,去除不标准的json数据output = json.loads(jsonstr) # 最终json数据items_list=output['data']['items_list']qqlist = set()for item in items_list: qqlist.add(item['uin'])# 获取谁在意我origin_friend_whocare = origin_friendcurl = origin_friend_whocare.replace('do=1', 'do=2')args = shlex.split(curl)result = subprocess.check_output(args).decode('utf-8')jsonstr = result[result.find('(') + 1: result.find(')', -1) - 1] # json字符串,去除不标准的json数据output = json.loads(jsonstr) # 最终json数据items_list=output['data']['items_list']for item in items_list: qqlist.add(item['uin'])# 打印信息并输出到文件print '获取QQ号个数'+str(len(qqlist))filename='qqlist.txt'fileobj = open(filename, 'w')result = [str(qq) + '\n' for qq in sorted(qqlist)]fileobj.writelines(result)fileobj.flush()fileobj.close()print '写入完成'
0 0
- Python2.7获取QQ空间部分好友
- Python2.7获取QQ空间好友头像
- Python2.7获取QQ空间全部好友
- Python2.7获取QQ好友头像
- 使用Python2.7和火狐浏览器下载QQ空间好友相册
- 使用Python2.7和火狐浏览器下载QQ空间好友相册(二)
- Python3.6获取QQ空间全部好友列表
- 获取QQ好友列表
- iOS QQ空间 好友分享
- Python2.7获取QQ照片墙
- 获取QQ好友共同好友列表信息
- 如何控制QQ好友访问空间?
- Python爬虫QQ空间好友说说
- 从非qq好友的校友空间破解qq号
- android QQ空间,QQ好友分享 SDK具体使用过程
- android 实现QQ好友分享和QQ空间分享
- android 实现QQ好友分享和QQ空间分享
- php获取qq好友列表的方法
- 充实的一天
- VS2013使用EF6与mysql数据库
- 字符串识别与过滤
- hust1344(阶层问题+暴力)
- UILabel属性
- Python2.7获取QQ空间部分好友
- Atitit.request http乱码的设计防止 检测与解决最近实践p825 attilax总结.doc
- Wow! Such Sequence!(线段树4893)
- 一天中时针和分钟重合的次数
- noip2004 火星人 (按照康托展开,从一个排列生成下一个排列)
- oracle网络配置listener.ora、sqlnet.ora、tnsnames.ora
- hust1346(两个线段的最近距离和最小距离)
- jQueryMobile的组件之弹出窗(popup)
- tabbar去线加背景图片