新浪微博后续json 数据分析和抓取

微博数据抓取下拉由json数据返回的动态数据
因为下拉的数据要不同的数据才能返回不同页码的数据,懒得分析参数了,
url 的参数是由首页数据的最后一个微博的参数决定的,没有整合到一起,这里只是做个示范,假定数据给定的情况,后续要加工成一体的。

#!/usr/bin/python
# -*- coding: UTF-8 -*-

#获取  新浪微薄 下拉后得到的微博信息  返回json数据
from bs4 import BeautifulSoup
import Auth as head
import requests

import time
def getnextinfo(): 
    t = time.time()
    nowTime = lambda:int(round(t * 1000))
    print (nowTime()); 
    url='https://weibo.com/p/aj/v6/mblog/mbloglist?ajwvr=6&domain=100505&refer_flag=0000015010_&from=feed&loc=avatar&is_all=1&pagebar=0&pl_name=Pl_Official_MyProfileFeed__21&id=1005051892059383&script_uri=/yishuwuyu&feed_type=0&page=1&pre_page=1&domain_op=100505&__rnd=1564487703911'


    header=head.getheader()

    html_doc=requests.get(url,headers=header)
    html=html_doc.json()
    table=html['data']
#print html['data']
    print '1111111111111111111111111111111111111111111111111111111'
    soup = BeautifulSoup(table, 'html.parser', from_encoding='utf-8')
    listcontent=soup.div.children
    for z in listcontent:
        s=BeautifulSoup(str(z), 'html.parser', from_encoding='utf-8')
        t=s.find('div',class_='WB_text W_f14')
        if t:
            a=BeautifulSoup(str(t), 'html.parser', from_encoding='utf-8')
            w= a.div
            print w.text
            print 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
head.getmianinfo()
getnextinfo()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值