这是我正在查看的URL:
url = https://i.instagram.com/api/v1/users/8538441802/info/
如果将此网址复制到Web浏览器的导航栏上,则会看到以下内容:
{"user": {"pk": 8538441802, "username": "bobby_ww4", "full_name": "\ud83c\udf78 B O B B Y \ud83c\udf78", "is_private": false, "profile_pic_url": "https://scontent-sjc3-1.cdninstagram.com/vp/8a743eb7285d9cec268248e7fe6b018e/5D0470C8/t51.2885-19/s150x150/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com", "profile_pic_id": "1963771869542832625_8538441802", "is_verified": false, "has_anonymous_profile_picture": false, "media_count": 42, "follower_count": 2132, "following_count": 2881, "following_tag_count": 0, "biography": "Cake murder 9may\nLUNATIC \ud83d\udc40\nFashionholic \ud83d\udc54\n Attrangi \nUncontrolled rage \ud83d\ude44\nKDM LOVER \u2620\nHold the sea in my embrance", "external_url": "", "total_igtv_videos": 0, "total_ar_effects": 0, "reel_auto_archive": "on", "usertags_count": 44, "is_favorite": false, "is_interest_account": false, "hd_profile_pic_versions": [{"width": 320, "height": 320, "url": "https://scontent-sjc3-1.cdninstagram.com/vp/e6dc6596c0fed678fe6e520e020a1cbc/5D1C6238/t51.2885-19/s320x320/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com"}, {"width": 640, "height": 640, "url": "https://scontent-sjc3-1.cdninstagram.com/vp/4dd3319b1972445ce27eed7c827afbc4/5D033F57/t51.2885-19/s640x640/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com"}], "hd_profile_pic_url_info": {"url": "https://scontent-sjc3-1.cdninstagram.com/vp/30ff98f96900aee2a5604b7d833e0e85/5D130A32/t51.2885-19/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com", "width": 1080, "height": 1080}, "mutual_followers_count": 0, "has_highlight_reels": true, "can_be_reported_as_fraud": false, "direct_messaging": "UNKNOWN", "fb_page_call_to_action_id": "", "address_street": "", "business_contact_method": "CALL", "category": "Fashion Model", "city_id": 106313309406070, "city_name": "Ludhiana, Punjab, India", "contact_phone_number": "+919914934996", "is_call_to_action_enabled": false, "latitude": 30.9, "longitude": 75.85, "public_email": "bobbyvaid1137@gmail.com", "public_phone_country_code": "91", "public_phone_number": "9914934996", "zip": "", "instagram_location_id": "", "is_business": true, "account_type": 2, "can_hide_category": false, "can_hide_public_contacts": false, "should_show_category": true, "should_show_public_contacts": true, "include_direct_blacklist_status": true, "is_potential_business": false, "is_bestie": false, "has_unseen_besties_media": false, "show_account_transparency_details": false, "auto_expand_chaining": false, "highlight_reshare_disabled": false}, "status": "ok"}
注意:您必须先登录Instagram才能查看以上内容。
以下是我使用请求阅读此页的行:
page = requests.get(url, headers={"User-Agent": "Mozilla"})
如果我看着page.text
,这就是我看到的:
{"user": {"pk": 8538441802, "username": "bobby_ww4", "full_name": "\ud83c\udf78 B O B B Y \ud83c\udf78", "is_private": false, "profile_pic_url": "https://scontent-sjc3-1.cdninstagram.com/vp/8a743eb7285d9cec268248e7fe6b018e/5D0470C8/t51.2885-19/s150x150/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com", "profile_pic_id": "1963771869542832625_8538441802", "is_verified": false, "has_anonymous_profile_picture": false, "media_count": 42, "follower_count": 2132, "following_count": 2881, "following_tag_count": 0, "biography": "Cake murder 9may\nLUNATIC \ud83d\udc40\nFashionholic \ud83d\udc54\n Attrangi \nUncontrolled rage \ud83d\ude44\nKDM LOVER \u2620\nHold the sea in my embrance", "external_url": "", "total_igtv_videos": 0, "total_ar_effects": 0, "reel_auto_archive": "on", "usertags_count": 44, "is_interest_account": false, "hd_profile_pic_versions": [{"width": 320, "height": 320, "url": "https://scontent-sjc3-1.cdninstagram.com/vp/e6dc6596c0fed678fe6e520e020a1cbc/5D1C6238/t51.2885-19/s320x320/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com"}, {"width": 640, "height": 640, "url": "https://scontent-sjc3-1.cdninstagram.com/vp/4dd3319b1972445ce27eed7c827afbc4/5D033F57/t51.2885-19/s640x640/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com"}], "hd_profile_pic_url_info": {"url": "https://scontent-sjc3-1.cdninstagram.com/vp/30ff98f96900aee2a5604b7d833e0e85/5D130A32/t51.2885-19/50103965_250281542552654_8842589758333911040_n.jpg?_nc_ht=scontent-sjc3-1.cdninstagram.com", "width": 1080, "height": 1080}, "has_highlight_reels": true, "can_be_reported_as_fraud": false, "is_potential_business": false, "auto_expand_chaining": false, "highlight_reshare_disabled": false}, "status": "ok"}
在网络浏览器上可以看到,我们可以看到一些信息,例如contact_phone_number
在page.txt
中看不到。
为什么会这样?我该如何使用requests
或其他Python函数来准确读取我在网络浏览器中看到的内容?