Use requests to get the API content of NetEase Cloud Music, but the result is not complete (browser access is normal)

problem description

Mini Program, who crawled the information of NetEase"s playlist, learned from Baidu that the API of NetEyun"s playlist is
http://music.163.com/api/play., so he started to use requests"s get method to get its content. However, the information obtained is incomplete, and it is suspected to be loaded step by step (while request only takes the first step)

.

the environmental background of the problems and what methods you have tried

system environment: Windows 7 x64Python 2.7.13recording 2.18.4
Development environment: PyCharm Community Version Edition 2017.2.3
tried methods:

  • get it directly
  • Save as a file and read in
  • stream = True

related codes

import requests
r = requests.get("http://music.163.com/api/playlist/detail?id=108101671")
quit()

what result do you expect? What is the error message actually seen?

expected result:
the playlist information of this test playlist is about 143KB. The browser can directly open this link to get the complete information (including all songs).

error message:
only got the playlist information (creator, follower, etc.) and first song , as follows:

{
    "result": {
        "subscribers": [
            
        ],
        "subscribed": false,
        "creator": {
            "defaultAvatar": false,
            "province": 120000,
            "authStatus": 0,
            "followed": false,
            "avatarUrl": "https://img.codeshelper.com/upload/img/2021/04/05/l23zteqz1hh15409.jpg",
            "accountStatus": 0,
            "gender": 1,
            "city": 120101,
            "birthday": 1004978050599,
            "userId": 90241279,
            "userType": 0,
            "nickname": "SHIIn_QInginz-",
            "signature": "",
            "description": "",
            "detailDescription": "",
            "avatarImgId": 109951163439237367,
            "backgroundImgId": 109951163445428833,
            "backgroundUrl": "https://img.codeshelper.com/upload/img/2021/04/05/dkt2jcxxtdt15410.jpg",
            "authority": 0,
            "mutual": false,
            "expertTags": null,
            "experts": null,
            "djStatus": 10,
            "vipType": 10,
            "remarkName": null,
            "avatarImgIdStr": "109951163439237367",
            "backgroundImgIdStr": "109951163445428833",
            "avatarImgId_str": "109951163439237367"
        },
        "artists": null,
        "tracks": [
            {
                "name": "UNHAPPY CLUB",
                "id": 1297493133,
                "position": 1,
                "alias": [
                    ": /  THIRD SEASON"
                ],
                "status": 0,
                "fee": 8,
                "copyrightId": 663018,
                "disc": "1",
                "no": 1,
                "artists": [
                    {
                        "name": "",
                        "id": 12203334,
                        "picId": 0,
                        "img1v1Id": 0,
                        "briefDesc": "",
                        "picUrl": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                        "img1v1Url": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                        "albumSize": 0,
                        "alias": [
                            
                        ],
                        "trans": "",
                        "musicSize": 0
                    }
                ],
                "album": {
                    "name": "Unhappy Club",
                    "id": 72056638,
                    "type": "EP/Single",
                    "size": 1,
                    "picId": 109951163433216811,
                    "blurPicUrl": "https://img.codeshelper.com/upload/img/2021/04/05/iupwiiat0dm15412.jpg",
                    "companyId": 0,
                    "pic": 109951163433216811,
                    "picUrl": "https://img.codeshelper.com/upload/img/2021/04/05/iupwiiat0dm15412.jpg",
                    "publishTime": 1532016000007,
                    "description": "",
                    "tags": "",
                    "company": "WARNER MUSIC JAPAN",
                    "briefDesc": "",
                    "artist": {
                        "name": "",
                        "id": 0,
                        "picId": 0,
                        "img1v1Id": 0,
                        "briefDesc": "",
                        "picUrl": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                        "img1v1Url": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                        "albumSize": 0,
                        "alias": [
                            
                        ],
                        "trans": "",
                        "musicSize": 0
                    },
                    "songs": [
                        
                    ],
                    "alias": [
                        
                    ],
                    "status": 0,
                    "copyrightId": 663018,
                    "commentThreadId": "R_AL_3_72056638",
                    "artists": [
                        {
                            "name": "",
                            "id": 12203334,
                            "picId": 0,
                            "img1v1Id": 0,
                            "briefDesc": "",
                            "picUrl": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                            "img1v1Url": "https://img.codeshelper.com/upload/img/2021/04/05/mwkhfvc2vkc15411.jpg",
                            "albumSize": 0,
                            "alias": [
                                
                            ],
                            "trans": "",
                            "musicSize": 0
                        }
                    ],
                    "subType": "",
                    "picId_str": "109951163433216811"
                },
                "starred": false,
                "popularity": 95.0,
                "score": 95,
                "starredNum": 0,
                "duration": 215225,
                "playedNum": 0,
                "dayPlays": 0,
                "hearTime": 0,
                "ringtone": null,
                "crbt": null,
                "audition": null,
                "copyFrom": "",
                "commentThreadId": "R_SO_4_1297493133",
                "rtUrl": null,
                "ftype": 0,
                "rtUrls": [
                    
                ],
                "copyright": 0,
                "hMusic": {
                    "name": "",
                    "id": 3417416777,
                    "size": 8610003,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 320000,
                    "playTime": 215225,
                    "volumeDelta": -3.0
                },
                "mMusic": {
                    "name": "",
                    "id": 3417416779,
                    "size": 5166019,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 192000,
                    "playTime": 215225,
                    "volumeDelta": -3.0
                },
                "lMusic": {
                    "name": "",
                    "id": 3417416780,
                    "size": 3444027,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 128000,
                    "playTime": 215225,
                    "volumeDelta": -3.0
                },
                "bMusic": {
                    "name": "",
                    "id": 3417416780,
                    "size": 3444027,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 128000,
                    "playTime": 215225,
                    "volumeDelta": -3.0
                },
                "mp3Url": null,
                "rtype": 0,
                "rurl": null,
                "mvid": 10749022
            }
        ],
        "ordered": true,
        "tags": [
            "",
            "ACG"
        ],
        "coverImgId": 7987951978316919,
        "createTime": 1442577242601,
        "coverImgUrl": "https://img.codeshelper.com/upload/img/2021/04/05/ombk1yp30nk15413.jpg",
        "userId": 90241279,
        "trackCount": 1,
        "adType": 0,
        "trackNumberUpdateTime": 1532953375747,
        "status": 0,
        "anonimous": false,
        "privacy": 0,
        "newImported": false,
        "updateTime": 1533445601163,
        "trackUpdateTime": 1533445934241,
        "playCount": 1861190,
        "specialType": 0,
        "subscribedCount": 81067,
        "cloudTrackCount": 0,
        "description": "",
        "highQuality": false,
        "totalDuration": 0,
        "commentThreadId": "A_PL_0_108101671",
        "name": "_()",
        "id": 108101671,
        "shareCount": 840,
        "commentCount": 1788
    },
    "code": 200
}

some information

browser: Chrome67.0
you can see from F12 that has only one GET request during the entire loading process. The json obtained by
is complete in format, so it may not be a network problem

.

I haven't seen such a detailed question for a long time, but you just lack a request header

import requests

headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
}

r = requests.get('http://music.163.com/api/playlist/detail?id=108101671', headers=headers)
print r.text
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bed02a-3108a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bed02a-3108a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?