# -*- coding:utf-8 -*-
import requests
import re
import time
class weibo():
def __init__(self):
self.weibo = []
def get_page1(self, url):
cookies = {}
cookie = 'SINAGLOBAL=2777936565689.7427.1466425410359; wb_bub_hot_1860241872=1; wb_g_minivideo_1860241872=1; SSOLoginState=1467537363; YF-Ugrow-G0=b02489d329584fca03ad6347fc915997; YF-V5-G0=b188043973f8ae1849ba6cd9ae007290; _s_tentry=-; Apache=7162702707573.771.1467538108120; ULV=1467538108217:14:3:1:7162702707573.771.1467538108120:1467373335174; YF-Page-G0=3d55e26bde550ac7b0d32a2ad7d6fa53; WBStore=8ca40a3ef06ad7b2|undefined; un=582602426@qq.com; wvr=6; gsid_CTandWM=4ubUCpOz5xZW3mcuHYb0I7NVTe4; SCF=AsG32LL5L-tXhp-r1nkoX4WKVRR90O-T9ecxTNXSsvXewAtX4tSPpWx4_jfwlYNTuRw6BS9oxKaK4muBwsqe3PQ.; SUB=_2A256f6BfDeTxGedG7VIT9C_EzD6IHXVZDJaXrDV8PUJbmtBeLRCikW8XOCjEMbO9_BI_WqTmNAYyV6Avlg..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFMl0_0K_GpCB8HR3kxdz7m5JpX5o2p5NHD95Qp1hq7eoBp1hMEWs4DqcjHi--ci-zfi-24i--ciKnRiK.7KsLV; SUHB=05iLVRXO83IiPd; UOR=,,link.zhihu.com'
for line in cookie.split(';'):
#其设置为1就会把字符串拆分成2份
name,value=line.strip().split('=',1)
cookies[name]=value
html = requests.get(url, cookies = cookies).text
#f.write(html.text.encode('utf-8'))
xunliehaos = re.findall(r'\w+-\w+-\w+-\w+', html, re.S)
for i in xunliehaos:
self.weibo.append(i)
def get_page2(self, url):
cookies = {}
cookie = 'SINAGLOBAL=2777936565689.7427.1466425410359; wb_bub_hot_1860241872=1; wb_g_minivideo_1860241872=1; SSOLoginState=1467537363; YF-Ugrow-G0=b02489d329584fca03ad6347fc915997; YF-V5-G0=b188043973f8ae1849ba6cd9ae007290; _s_tentry=-; Apache=7162702707573.771.1467538108120; ULV=1467538108217:14:3:1:7162702707573.771.1467538108120:1467373335174; YF-Page-G0=3d55e26bde550ac7b0d32a2ad7d6fa53; WBStore=8ca40a3ef06ad7b2|undefined; un=582602426@qq.com; wvr=6; gsid_CTandWM=4ubUCpOz5xZW3mcuHYb0I7NVTe4; SCF=AsG32LL5L-tXhp-r1nkoX4WKVRR90O-T9ecxTNXSsvXewAtX4tSPpWx4_jfwlYNTuRw6BS9oxKaK4muBwsqe3PQ.; SUB=_2A256f6BfDeTxGedG7VIT9C_EzD6IHXVZDJaXrDV8PUJbmtBeLRCikW8XOCjEMbO9_BI_WqTmNAYyV6Avlg..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFMl0_0K_GpCB8HR3kxdz7m5JpX5o2p5NHD95Qp1hq7eoBp1hMEWs4DqcjHi--ci-zfi-24i--ciKnRiK.7KsLV; SUHB=05iLVRXO83IiPd; UOR=,,link.zhihu.com'
for line in cookie.split(';'):
#其设置为1就会把字符串拆分成2份
name,value=line.strip().split('=',1)
cookies[name]=value
html1 = requests.get(url, cookies = cookies).text
new = re.findall(r'\w+-\w+-\w+-\w+', html1, re.S)[1]
if new not in self.weibo:
print new
url = 'http://weibo.com/p/1005051860241872/home?from=page_100505_profile&wvr=6&mod=data&is_all=1'
weib = weibo()
while 1:
weib.get_page1(url)
time.sleep(15)
weib.get_page2(url)
爬微博序列号
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 一、回顾 我们之前利用Scrapy爬取豆瓣网站信息时,直接通过加载目标URL返回的Response得到想要的值。我...
- 随着公司的并行项目越来越多,Android新项目初始化的变成一个问题,一开始是每个人建立项目不一样,为此设计了清单...