当前位置:   article > 正文

新浪微博后续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()

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号