把微博關注的主頁網址存下來
来源:互联网 发布:数据库管理系统属于 编辑:程序博客网 时间:2024/05/16 23:50
把微博我關注了的主頁網址存下來
有其麼用呢
以後我再寫一個「和某天相比,今天我關注了的主頁有哪些增減」
#coding=utf-8import requestsimport sysimport reimport timeimport datetimedef howmanypage(cook,url): urlre=requests.get(url,cookies=cook) html=urlre.text print(html.encode('utf-8')) print('') pagenum=re.search('" /> (\d+)/(\d+)(.*?)</div></form>',html,re.S) return(pagenum.group(2))def findpeople(cook,url): howmanypeople=0 f=open('people/%s.txt'%time.strftime("%Y-%m-%d"),'r') a=f.read() f.close() f=open('people/%s.txt'%time.strftime("%Y-%m-%d"),'w+') f.write(a) urlre=requests.get(url,cookies=cook) html=urlre.text peoplelink=re.findall('px"><a href="(.*?)"><img src="',html,re.S) for pl in peoplelink: howmanypeople=howmanypeople+1 f.write(pl+'\n') f.close() if howmanypeople<1: print('%s---%d'%(url,howmanypeople)) return howmanypeopleif __name__=='__main__': cook={"Cookie":""} i=1 url='http://weibo.cn/00000000/follow?page=%d'%i pagenum=howmanypage(cook,url) print(pagenum) howmanypeople=0 f=open('people/%s.txt'%time.strftime("%Y-%m-%d"),'w+') f.write('') f.close() for i in range(1,int(pagenum)+1): print(i) url='http://weibo.cn/00000000/follow?page=%d'%i howmanypeople=howmanypeople+findpeople(cook,url) f=open('people/%s.txt'%time.strftime("%Y-%m-%d"),'r') a=f.read() f.close() f=open('people/%s.txt'%time.strftime("%Y-%m-%d"),'w+') f.write('%d\n'%howmanypeople) f.write(a) f.close()
0 0
- 把微博關注的主頁網址存下來
- 把人变傻的问题
- 把行变列的sql
- 把数码的境界
- 模型的把控
- 把token的<>去掉
- 细节的把控
- 把网站做好的随想
- 把变化的提取出来!
- 两把剪刀的故事
- 把自己喜欢的留下
- 把listbox的值存到xml
- 离婚把!唯一的选择!
- 把复杂的事情简单化
- 把简单的事情做好
- 把eclipse变成中文的
- 下雨天的那把伞
- 把想不通的事想通
- STM32系列第9篇--外部中断
- 修改frame快捷方法,不必再繁琐的计算
- IO-3
- CUDA任意矩阵相乘 TLP最终版
- HBuilder真机联调iPhone手机设备问题
- 把微博關注的主頁網址存下來
- 文件操作
- 使用PowerDesigner画图详细教程——PMD
- linux各种中文乱码解决办法整理
- 圣思源-张龙-Java SE 第八讲(理解面向对象程序设计)
- 跨浏览器的事件对象
- 关于排序算法
- Android中的数据存储方式
- IO-4