In [1]:
import time
import requests
headers = {'User-Agent': 'WeRead/1.5.8 WRBrand/Meizu Dalvik/2.1.0 (Linux; U; Android 5.1; M3s Build/LMY47I)',\
           'accessToken': 'QaJPvQ4t',\
           'vid': '7649467'}
from pymongo import MongoClient
client = MongoClient()
db = client.weread
books = db.books
users = db.users
categories = db.categories
booksrd = db.booksrd
from py2neo.ogm import GraphObject, Property, Label, RelatedObjects, RelatedTo, RelatedFrom
from py2neo import Graph, NodeSelector
graph = Graph()
selector = NodeSelector(graph)

In [2]:
url_base = 'https://i.weread.qq.com/'
#user
url_user_profile = '''https://i.weread.qq.com/user/profile?vid={}&gender=1&signature=1\
                        &vDesc=1&location=1&totalReadingTime=1&currentReadingTime=1&finishedBookCount=1\
                        &followerCount=1&followingCount=1&buyCount=1&reviewCount=1&reviewLikedCount=1\
                        &reviewCommentedCount=1&likeBookCount=1&isFollowing=1&isFollower=1&isBlackMe=1\
                        &isInBlackList=1&bookReviewCount=1&noteBookCount=1&exchangedMoney=0&recentReadingBooks=0\
                        &booklistCount=1&booklistCollectCount=1&articleBookId=1&articleCount=1&articleDraftCount=1\
                        &articleReadCount=1&articleSubscribeCount=1&articleWordCount=1&lectureCount=1&\
                        lectureListenCount=1&lectureLikedCount=1&lectureCommentedCount=1 
                    '''
url_book_finishreading = url_base+'book/finishreading?userVid={}'
url_shelf_friendsshelf = url_base+'shelf/friendsshelf?userVid={}'
#book
url_book_info = url_base+'book/info?bookId={}'
url_book_chapterInfos = url_base+'book/chapterInfos'
url_book_review_list = url_base+'review/list?listType=3&bookId={}&maxIdx=1000000&tips=1&listMode=1'
url_store_category_0 = url_base+'store/category?categoryId={}&synckey=0&count=1&maxIdx=0'
url_store_category_1 = url_base+'store/category?categoryId={}&synckey=0&maxIdx=0'
def get_from_api(api,id_):
    if api == url_book_chapterInfos:
        data = {"bookIds":[id_],"synckeys":[0]}
        r = requests.post(api,headers=headers,data=data)
    else:
        r = requests.get(api.format(id_),headers=headers)
    j = r.json()
    try:
        if j['errcode'] == -2014:
            print u'请求频率过高 ',
            time.sleep(15)
            return get_from_api(api,id_)
        if j['errcode'] == -2012:
            print u'登录超时 ',
            raise Exception(u'登录超时')
    except:
        return j
#categoryIds = [13100,13200,13400,13500,13600,13700,2100,14000,14100,14200,15700,14300,14400,14500,14800,15000,15600,16400,16800,19000,5000]
def get_category(categoryIds): for categoryId in categoryIds: print categoryId, if categories.find_one({'_id':categoryId}): pass else: try: totalCount = get_from_api(url_store_category_0,categoryId)['totalCount'] print totalCount if totalCount > 0: categories_data = get_from_api(url_store_category_1+'&count='+str(totalCount),categoryId) categories_data['_id'] = categoryId #print url_store_category_1+'&count='+str(totalCount) categories.insert_one(categories_data) except: pass
#5000 20000 30000 #category_5000 = [i for i in xrange(20000,40000) if str(i)[1] == '0' and str(i)[2] == '0'] #category_5000
#get_category(categoryIds)
categories_ = categories.find({})
categories_list = []
for c in categories_: for b in c['books']: categories_list.append(b['bookInfo']['bookId'])
categories_list = [int(b) for b in categories_list]
len(categories_list)
categories.insert_one({'_id':0,'data':categories_list})
booklist = categories.find({'_id':0})[0]
booklist = [b for b in booklist['data']]
booklist[:30]

In [3]:
# url_review_sametimereading 
url_review_sametimereading_0 = url_base+'review/sametimereading?bookId={}&maxIdx=0&count=3'
url_review_sametimereading_1 = url_base+'review/sametimereading?bookId={}&count=100'
r = requests.get(url_review_sametimereading_0.format(852290),headers=headers)

In [4]:
j = r.json()
len(j['readingList'])
print j['readingList'][0]['review']['userVid'],j['readingList'][-1]['review']['userVid']


7511027 16125083

In [5]:
j


Out[5]:
{u'maxShowCount': 50,
 u'readingList': [{u'finishedBookCount': 0,
   u'gender': 1,
   u'location': u'\u6c5f\u82cf \u5e38\u5dde',
   u'review': {u'author': {u'avatar': u'http://wx.qlogo.cn/mmopen/FicCThRvK2Iy9mTp1VUHCxd5z9Zg3TKUNib4Fu1KE92htNaj3XAbXJVpxhVqReFJXUKENnfn9ZOx8SDPgvgFcm8JLC5fXZ45zu/0',
     u'isFollower': 0,
     u'isFollowing': 0,
     u'name': u'\u5fc3\u7406\u4ea4\u6d41',
     u'userVid': 7511027},
    u'book': {u'author': u'\u5c24\u74e6\u5c14\xb7\u8d6b\u62c9\u5229',
     u'bookId': u'852290',
     u'bookStatus': 1,
     u'cover': u'http://wfqqreader.3g.qq.com/cover/290/852290/s_852290.jpg',
     u'format': u'epub',
     u'soldout': 0,
     u'title': u'\u672a\u6765\u7b80\u53f2\uff1a\u4ece\u667a\u4eba\u5230\u667a\u795e',
     u'version': 2017835511},
    u'bookId': u'852290',
    u'chapterIdx': 11,
    u'content': u'100',
    u'createTime': 1494608186,
    u'finishReading': 1,
    u'isPrivate': 0,
    u'noteCount': 514,
    u'readingTime': 44463,
    u'reviewId': u'7511027_6PNah8vVi',
    u'startReadingTime': 1492435604,
    u'type': 3,
    u'userVid': 7511027},
   u'reviewCount': 0,
   u'reviewId': u'7511027_6PNah8vVi',
   u'signature': u'',
   u'totalReadingTime': 0,
   u'vid': 7511027,
   u'wonderReview': {u'_fljmask': 0,
    u'abstract': u'\u771f\u6b63\u8ba9\u6bd4\u8d5b\u5982\u6b64\u5438\u5f15\u4eba\u7684\uff0c\u5c31\u662f\u90a3\u4e9b\u4ee4\u4eba\u5f00\u5fc3\u7684\u611f\u89c9\u3002',
    u'bookId': u'852290',
    u'bookVersion': 2017835511,
    u'chapterUid': 3,
    u'content': u'\u6240\u4ee5\uff0c\u4ece\u5143\u8ba4\u77e5\u7684\u89d2\u5ea6\u63a8\u6f14\uff0c\u5982\u4f55\u6cbb\u7f51\u763e\uff0c\u5c31\u662f\u5c06\u8fd9\u79cd\u5feb\u4e50\u53d8\u6210\u70e6\u607c\u548c\u4e0d\u6109\u5feb\uff0c\u5728\u8fd9\u79cd\u8fc7\u7a0b\u4e2d\u4e0d\u65ad\u5236\u9020\u4e0d\u5feb\u4e50\uff0c\u800c\u4e14\u76f4\u5230\u7ed3\u679c\u90fd\u662f\u4e0d\u5feb\u4e50\u3002\u4f46\u662f\uff0c\u8fd9\u79cd\u8ffd\u9010\u6210\u529f\u7684\u5feb\u4e50\u662f\u751f\u6d3b\u524d\u8fdb\u7684\u52a8\u529b\u3002\u90a3\u4e48\uff0c\u771f\u6b63\u6cbb\u7597\u7f51\u763e\u4e5f\u8bb8\u6709\u4e24\u4e2a\u65b9\u6cd5:\u4e00\uff0c\u5728\u5b69\u5b50\u5c0f\u7684\u65f6\u5019\u5c31\u57f9\u517b\u5b69\u5b50\u7684\u5fcd\u8010\u529b\uff1b\u4e8c\u3001\u4ece\u5c0f\u4e0d\u8ba9\u5b69\u5b50\u63a5\u89e6\u7535\u8111\u76f8\u5173\u7684\u4e1c\u897f\u3002\u4f46\u662f\uff0c\u7b2c\u4e00\u4e2a\u65b9\u6cd5\u66f4\u53ef\u9760\uff0c\u56e0\u4e3a\u7b2c\u4e8c\u4e2a\u65b9\u6cd5\u4f1a\u5bfc\u81f4\u5b69\u5b50\u6210\u5e74\u540e\u5728\u73b0\u4ee3\u5316\u77e5\u8bc6\u4e0a\u7684\u77ed\u677f\u3002',
    u'createTime': 1492697383,
    u'htmlContent': u'',
    u'isPrivate': 0,
    u'range': u'43080-43104',
    u'reviewId': u'7511027_6PRM1cnmm',
    u'type': 1,
    u'userVid': 7511027,
    u'wechatSns': 0}},
  {u'finishedBookCount': 0,
   u'gender': 2,
   u'location': u'\u5e7f\u4e1c \u97f6\u5173',
   u'review': {u'author': {u'avatar': u'http://wx.qlogo.cn/mmopen/FicCThRvK2IyAGiafQe2hpYIicYTnNts4nv0rho0se9xPACfmk0HkyHuI1s2A0f9PDQspExZdiafv89vUwhSbiahLsYRn17hE0fQT/0',
     u'isFollower': 0,
     u'isFollowing': 0,
     u'name': u'\u6f2b\u821e\u7ea2\u8896',
     u'userVid': 29208111},
    u'book': {u'author': u'\u5c24\u74e6\u5c14\xb7\u8d6b\u62c9\u5229',
     u'bookId': u'852290',
     u'bookStatus': 1,
     u'cover': u'http://wfqqreader.3g.qq.com/cover/290/852290/s_852290.jpg',
     u'format': u'epub',
     u'soldout': 0,
     u'title': u'\u672a\u6765\u7b80\u53f2\uff1a\u4ece\u667a\u4eba\u5230\u667a\u795e',
     u'version': 2017835511},
    u'bookId': u'852290',
    u'chapterIdx': 6,
    u'content': u'29',
    u'createTime': 1494607328,
    u'finishReading': 0,
    u'isPrivate': 0,
    u'noteCount': 14,
    u'readingTime': 19693,
    u'reviewId': u'29208111_6OmqOAsLr',
    u'startReadingTime': 1487395535,
    u'type': 3,
    u'userVid': 29208111},
   u'reviewCount': 0,
   u'reviewId': u'29208111_6OmqOAsLr',
   u'signature': u'',
   u'totalReadingTime': 0,
   u'vid': 29208111,
   u'wonderReview': {u'_fljmask': 0,
    u'abstract': u'\u9760\u7740\u75ab\u82d7\u3001\u836f\u7269\u3001\u6fc0\u7d20\u3001\u6740\u866b\u5242\u3001\u4e2d\u592e\u7a7a\u8c03\u7cfb\u7edf\u3001\u81ea\u52a8\u5582\u98df\u88c5\u7f6e\uff0c\u73b0\u5728\u6211\u4eec\u80fd\u628a\u6210\u5343\u4e0a\u4e07\u7684\u732a\u3001\u725b\u3001\u9e21\u585e\u8fdb\u6574\u800c\u8fd1\u5e74\u6765\uff0c\u968f\u7740\u4eba\u7c7b\u5f00\u59cb\u91cd\u65b0\u601d\u8003\u4eba\u4e0e\u52a8\u7269\u7684\u5173\u7cfb\uff0c\u8fd9\u6837\u7684\u505a\u6cd5\u5f00\u59cb\u62db\u81f4\u8d8a\u6765\u8d8a\u591a\u7684\u6279\u8bc4\u3002\u5ffd\u7136\u4e4b\u95f4\uff0c\u6211\u4eec\u5bf9\u4e8e\u6240\u8c13\u4f4e\u7b49\u751f\u7269\u7684\u547d\u8fd0\u6709\u4e86\u524d\u6240\u672a\u6709\u7684\u5174\u8da3\uff0c\u6216\u8bb8\u4e5f\u662f\u56e0\u4e3a\u81ea\u5df1\u5feb\u8981\u53d8\u6210\u4f4e\u7b49\u751f\u7269\u4e86\uff1f\u5982\u679c\u8ba1\u7b97\u673a\u7a0b\u5e8f\u62e5\u6709\u4e86\u8d85\u4e4e\u4eba\u7c7b\u7684\u667a\u6167\u3001\u524d\u6240\u672a\u6709\u7684\u80fd\u529b\uff0c\u6211\u4eec\u4f1a\u4e0d\u4f1a\u8ba4\u4e3a\u8fd9\u4e9b\u7a0b\u5e8f\u6bd4\u4eba\u7c7b\u66f4\u91cd\u8981\uff1f\u4e3e\u4f8b\u6765\u8bf4\uff0c\u4eba\u5de5\u667a\u80fd\u4f1a\u4e0d\u4f1a\u5229\u7528\u4eba\u7c7b\uff0c\u751a\u81f3\u4e3a\u4e86\u5b83\u81ea\u8eab\u7684\u9700\u6c42\u548c\u6b32\u671b\u800c\u6740\u6b7b\u4eba\u7c7b\uff1f\u5982',
    u'bookId': u'852290',
    u'bookVersion': 2017835511,
    u'chapterUid': 5,
    u'content': u'\u8d8a\u662f\u73b0\u4ee3\u751f\u7269\u5c31\u8d8a\u7cdf\u6467\u6b8b\uff0c\u795e\u6027\u4e0d\u5982\u4eba\u6027\u3002\u90a3\u73b0\u4ee3\u7684\u4eba\u6027\u53c8\u8bf4\u660e\u4e86\u4ec0\u4e48\u3002',
    u'createTime': 1493568482,
    u'htmlContent': u'',
    u'isPrivate': 0,
    u'range': u'38447',
    u'reviewId': u'29208111_6Q76RyY7D',
    u'type': 1,
    u'userVid': 29208111,
    u'wechatSns': 0}},
  {u'finishedBookCount': 0,
   u'gender': 1,
   u'likes': [{u'avatar': u'http://wx.qlogo.cn/mmopen/XpytRujVypOteWy0jU4ERibvqxJHe3C0htUk66wS5opMQX0gzOWTakSplnib3iaEBhBCqvicqVHf8jUichUGHx5rtYuPV4Gz9SA7w/0',
     u'isFollower': 0,
     u'isFollowing': 0,
     u'isV': 0,
     u'name': u'\u6a59\u5c0f\u55b5\U0001f34e',
     u'userVid': 20536569,
     u'vDesc': u'\u751f\u547d\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u662f\u7231\u548c\u5e0c\u671b'},
    {u'avatar': u'http://wx.qlogo.cn/mmopen/Q3auHgzwzM4xMCv10ib0MqDEdEJIicaEe4UAtfUDnFJ8bbfSJKCRWC5jkO5Ibo09jhljW05ibLUuAwj54ibheobNeG3Aj8mFaTwkT57syictFhXA/0',
     u'isFollower': 0,
     u'isFollowing': 0,
     u'name': u'\u5de6\u83ab',
     u'userVid': 16125083}],
   u'location': u'',
   u'review': {u'author': {u'avatar': u'http://wx.qlogo.cn/mmopen/Q3auHgzwzM4xMCv10ib0MqDEdEJIicaEe4UAtfUDnFJ8bbfSJKCRWC5jkO5Ibo09jhljW05ibLUuAwj54ibheobNeG3Aj8mFaTwkT57syictFhXA/0',
     u'isFollower': 0,
     u'isFollowing': 0,
     u'name': u'\u5de6\u83ab',
     u'userVid': 16125083},
    u'book': {u'author': u'\u5c24\u74e6\u5c14\xb7\u8d6b\u62c9\u5229',
     u'bookId': u'852290',
     u'bookStatus': 1,
     u'cover': u'http://wfqqreader.3g.qq.com/cover/290/852290/s_852290.jpg',
     u'format': u'epub',
     u'soldout': 0,
     u'title': u'\u672a\u6765\u7b80\u53f2\uff1a\u4ece\u667a\u4eba\u5230\u667a\u795e',
     u'version': 2017835511},
    u'bookId': u'852290',
    u'chapterIdx': 10,
    u'content': u'54',
    u'createTime': 1494606509,
    u'finishReading': 0,
    u'isPrivate': 0,
    u'noteCount': 36,
    u'readingTime': 47763,
    u'reviewId': u'16125083_6PDahw1MC',
    u'startReadingTime': 1491867607,
    u'type': 3,
    u'userVid': 16125083},
   u'reviewCount': 0,
   u'reviewId': u'16125083_6PDahw1MC',
   u'signature': u'',
   u'totalReadingTime': 0,
   u'vid': 16125083,
   u'wonderReview': {u'_fljmask': 0,
    u'abstract': u'\u53c8\u6709\u591a\u5927\u53ef\u80fd\u5c06\u4f1a\u8d85\u8fc7\u6211\u4eec\uff1f\n\u4e0b\u4e00\u7ae0\u5c06\u8ba8\u8bba\u667a\u4eba\u7684\u672c\u8d28\u548c\u80fd\u529b\uff0c\u4e00\u65b9\u9762\u8fdb\u4e00\u6b65\u7406\u89e3\u6211\u4eec\u4e0e\u5176\u4ed6\u52a8\u7269\u7684\u5173\u7cfb\uff0c\u53e6\u4e00\u65b9\u9762\u4e5f\u8981\u770b\u770b\u4eba\u7c7b\u53ef\u80fd\u7684\u672a\u6765\uff0c\u4ee5\u53ca\u4eba\u7c7b\u4e0e\u8d85\u4eba\u7c7b\u53ef\u80fd\u6709\u600e\u6837\u7684\u5173\u7cfb\u3002\n',
    u'bookId': u'852290',
    u'bookVersion': 2017835511,
    u'chapterUid': 5,
    u'content': u'\u5168\u7403\u5927\u578b\u751f\u7269\u6709\u8d85\u8fc790%\u4e0d\u662f\u4eba\u7c7b\u5c31\u662f\u5bb6\u755c\n\u6380\u5f00\u7b2c\u4e8c\u7ae0\uff0c\u9996\u5148\u6620\u5165\u773c\u5e18\u7684\u5c31\u662f\u8fd9\u4e48\u4e00\u53e5\u8bdd\uff0c\u5e73\u6de1\u65e0\u5947\u5374\u53c8\u5f15\u4eba\u65e0\u9650\u9050\u60f3\uff5e\n\n                   \u7b2c\u4e8c\u7ae0\u4eba\u7c7b\u7684\u4e16\u754c\n\u5927\u4f53\u5206\u4e3a\u4e09\u4e2a\u65f6\u4ee3\n\u72e9\u730e\u91c7\u96c6\u65f6\u4ee3\n\u519c\u4e1a\u517b\u6b96\u65f6\u4ee3\n\u5de5\u4e1a\u79d1\u6280\u65f6\u4ee3\n\u7b14\u8005\u5206\u522b\u4ee5\u795e\u8bdd\uff0c\u53e4\u7c4d\u4e3a\u53c2\u7167\uff0c\u4eff\u4f5b\u8fd8\u539f\u4e86\u5c11\u4e8e\u4e09\u4e2a\u65f6\u4ee3\u7684\u539f\u578b\uff08\u4eba\u7c7b\uff09\n\u7b14\u8005\u6682\u5c06\u72e9\u730e\u91c7\u96c6\u65f6\u4ee3\u7684\u5148\u7956\u5f52\u7eb3\u4e3a\u6cdb\u7075\u8bba\u8005\uff0c\u519c\u4e1a\u517b\u6b96\u65f6\u4ee3\u548c\u5de5\u4e1a\u79d1\u6280\u65f6\u4ee3\u5219\u662f\u6709\u795e\u8bba\u548c\u4eba\u6587\u4e3b\u4e49\u7684\u5929\u4e0b\u3002\u8fd9\u4e9b\u4e3b\u5bfc\u5f53\u4e16\u4eba\u7c7b\u7684\u601d\u60f3\u4e4d\u4e00\u770b\u9a6c\u725b\u5176\u98ce\uff0c\u4f46\u4e00\u5207\u53d8\u5316\u7684\u6839\u6e90\u4f9d\u65e7\u662f\u751f\u5b58\uff5e\n\u72e9\u730e\u7684\u5148\u7956\u4e3a\u4e86\u751f\u5b58\uff0c\u4e0d\u5f97\u4e0d\u8352\u91ce\u89c5\u98df\uff0c\u90a3\u4e48\u5728\u6210\u4e3a\u730e\u4eba\u7684\u90a3\u4e00\u523b\uff0c\u4e5f\u540c\u6837\u80a9\u8d1f\u4e86\u730e\u7269\u7684\u8eab\u4efd\u3002\u751f\u5b58\u9700\u8981\u5b66\u4f1a\u4e0e\u540c\u4e00\u7247\u571f\u5730\u4e0a\u522b\u7684\u52a8\u690d\u7269\u8c08\u5224\u59a5\u534f\uff5e\n\u800c\u519c\u4e1a\u65f6\u4ee3\u7684\u4eba\u7c7b\uff0c\u5b66\u4f1a\u4e86\u517b\u6b96\uff0c\u51cf\u5c11\u4e86\u5916\u51fa\u89c5\u98df\u7684\u6b21\u6570\uff0c\u751f\u547d\u4e0d\u518d\u53d7\u8feb\u4e8e\u522b\u7684\u751f\u7269\uff0c\u9010\u6e10\u8131\u79bb\u4e86\u56fa\u6709\u98df\u7269\u94fe\uff0c\u90a3\u4e48\u60f3\u8131\u9896\u800c\u51fa\u81ea\u7136\u9700\u8981\u4e9b\u6b63\u5f53\u7684\u7406\u7531\uff0c\u4e8e\u662f\u5409\u5c14\u4f3d\u7f8e\u4ec0\u795e\u8bdd\uff0c\u521b\u4e16\u7eaa\uff0c\u5723\u7ecf\u51fa\u73b0\u4e86\uff5e\u5728\u6b64\u4ee5\u540e\u4eba\u7c7b\u660e\u767d\u4e86\uff0c\u81ea\u5df1\u4e0d\u540c\u4e8e\u52a8\u7269\uff0c\u662f\u7531\u4e07\u80fd\u7684\u795e\u5355\u72ec\u521b\u9020\u800c\u751f\uff0c\u773c\u524d\u522b\u7684\u751f\u547d\u90fd\u662f\u81ea\u5df1\u7684\u4f34\u751f\u7269\u3002\u4f46\u5373\u4fbf\u5982\u6b64\u4eba\u7c7b\u751f\u5b58\u4f9d\u65e7\u53d7\u7740\u5929\u707e\u5730\u7978\u7684\u5f71\u54cd\uff0c\u6240\u4ee5\u6211\u4eec\u66f4\u9700\u8981\u5411\u795e\u59a5\u534f\u6c42\u52a9\uff5e\n\u73b0\u5982\u4eca\u6211\u4eec\u751f\u6d3b\u7684\u65f6\u4ee3\u53c8\u662f\u4ec0\u4e48\u6837\u5b50\u5462\uff0c\u7b14\u8005\u5728\u6b64\u7528\u4e86\u4e00\u8fde\u4e32\u7edd\u5999\u7684\u6bd4\u55bb\u8bc1\u5b9e\u4e86\u4e00\u53e5\u8bdd\n21\u4e16\u7eaa\u662f\u4e00\u4e2a\u7b97\u6cd5\u4e3b\u5bfc\u7684\u4e16\u7eaa\n\u6240\u8c13\u4e00\u8bed\u70b9\u9192\u68a6\u4e2d\u4eba\uff0c\u6211\u8eab\u5728\u5176\u4e2d\u5374\u4e00\u76f4\u7ba1\u7aa5\u7684\u8ba4\u4e3a\u7b97\u6cd5\u662f\u7406\u5de5\u79d1\u7684\u4ee3\u540d\u8bcd\uff5e\u6587\u4e2d\u63d0\u5230\u7684\u751f\u7269\u7b97\u6cd5\u66f4\u662f\u8ba9\u6211\u8033\u76ee\u4e00\u65b0\uff0c\u770b\u7684\u6211\u5982\u75f4\u5982\u9189\uff5e\n\u4eba\u7c7b\u670999%\u7684\u51b3\u5b9a\uff0c\u5305\u62ec\u5173\u4e8e\u914d\u5076\u3001\u4e8b\u4e1a\u548c\u4f4f\u5904\u7684\u91cd\u8981\u6289\u62e9\uff0c\u90fd\u662f\u7531\u5404\u79cd\u8fdb\u5316\u800c\u6210\u7684\u7b97\u6cd5\u6765\u5904\u7406\uff0c\u6211\u4eec\u628a\u8fd9\u4e9b\u7b97\u6cd5\u79f0\u4e3a\u611f\u89c9\u3001\u60c5\u611f\u548c\u6b32\u671b\u3002\n21\u4e16\u7eaa\u7ecf\u8fc7\u79d1\u6280\u9769\u547d\u6d17\u793c\u7684\u4eba\u7c7b\uff0c\u89e3\u51b3\u4e86\u56f0\u6270\u5148\u7956\u51e0\u5343\u5e74\u7684\u751f\u5b58\u95ee\u9898\n\u9965\u8352\uff0c\u761f\u75ab\uff0c\u6218\u4e89\uff0c\n\u7269\u8d28\u5f62\u6001\u6709\u673a\u5230\u65e0\u673a\u53d8\u5316\n\u5e76\u4e14\u8863\u98df\u4f4f\u884c\u7761\u7b49\u7269\u8d28\u6b32\u4e0d\u65ad\u521b\u65b0\u9ad8\n\u4e0d\u9700\u8981\u5411\u4efb\u4f55\u5b58\u5728\u59a5\u534f\u540e\uff5e\u4eba\u6587\u4e3b\u4e49\u8bde\u751f\n\u8fd9\u4e2a\u65f6\u4ee3\u7684\u4eba\u7c7b\u5df2\u7ecf\u5f00\u59cb\u5411\u795e\u7684\u4f4d\u7f6e\u53d1\u8d77\u731b\u70c8\u7684\u8fdb\u653b\u3002\n\u540c\u4e00\u65f6\u523b\u7684\u6211\u4eec\u4e5f\u8d8a\u6765\u8d8a\u9700\u8981\u77e5\u9053\u4e3a\u4ec0\u4e48\n\u8131\u9896\u800c\u51fa\u7684\u751f\u7269\uff0c\u662f\u4eba\uff01',
    u'createTime': 1493218148,
    u'htmlContent': u'',
    u'isPrivate': 0,
    u'range': u'38983',
    u'reviewId': u'16125083_6Q0WsoGre',
    u'type': 1,
    u'userVid': 16125083,
    u'wechatSns': 0}}],
 u'totalCount': 1849}

In [11]:
j['totalCount']/500


Out[11]:
3

In [9]:
j = r.json()
len(j['readingList'])
print j['readingList'][0]['review']['userVid'],j['readingList'][-1]['review']['userVid']


30604467 30604467

In [19]:
def get_review_sametimereading(bookIds):
    for bookId in bookIds:
        print bookId,
        if booksrd.find_one({'_id':bookId}):
            pass
        else:
            #try:
            totalCount = get_from_api(url_review_sametimereading_0,bookId)['totalCount']
            print totalCount
            if totalCount > 0:
                books_data = {}
                books_data['_id'] = bookId
                books_data['totalCount'] = totalCount
                books_data['readingList'] = []
                for tc in xrange(totalCount/100+1):
                    print tc
                    books_data['readingList'].extend(get_from_api(url_review_sametimereading_1+'&maxIdx='+str(tc*100),bookId)['readingList'])
                #print url_store_category_1+'&count='+str(totalCount)
                #booksrd.insert_one(books_data)
            #except:
             #   pass

In [20]:
get_review_sametimereading([852290])


852290 1851
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

In [ ]: