简体   繁体   English

将请求从curl重写为python请求

[英]post request rewrite from curl to python requests

Why my post request via os.system('''curl ... ''') works correctly, 为什么我通过os.system('''curl ...''')的发布请求可以正常工作,
and the 'requests' analogue does not? 而“请求”类比不?

import requests

 .....

headers = {'content-type': 'application/x-www-form-urlencoded'}

r = requests.post('https://www.instagram.com/web/friendships/' + uid + '/unfollow/', headers=headers, data={'origin': 'https://www.instagram.com', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'uk,en-US;q=0.8,en;q=0.6', 'x-requested-with': 'XMLHttpRequest', 'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Mobile Safari/537.36', 'cookie': 'mid=WFgEmgAEAAFwxSdDXrfo8AAFCuHb; datr=hapZWMkpCVayEtqUE9QZ1L_R;sessionid=IGSC13c5de61354c258b1d0a65658184b39292f3b37a6502121f2adc55f7f8477621%3ACjRnOP6jWX4XtHYSlGsnReUQfbE3Knqc%3A%7B%22_token_ver%22%3A2%2C%22_auth_user_id%22%3A'+myid+'%2C%22_token%22%3A%22'+myid+'%3Afj3xkSGeTR3houFF08iwxKCWHEWOt6bi%3Adb47725d645f676bb23b2df6de97e39f435ab84078e36fcce4b86979036aa792%22%2C%22asns%22%3A%7B%22'+publicIp+'%22%3A31148%2C%22time%22%3A1483005349%7D%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22last_refreshed%22%3A1483005349.437956%2C%22_platform%22%3A4%2C%22_auth_user_hash%22%3A%22%22%7D; ig_pr=1; ig_vw=1367; csrftoken=3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f; ds_user_id='+myid,
    'x-csrftoken': '3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f', 'x-instagram-ajax': '1', 'accept': '*/*', 'referer': 'https://www.instagram.com/'+username+'/following/', 'authority': 'www.instagram.com', 'content-length': '0', 'dnt': '1'})
print(r.status_code, r.reason) # 200 OK, but not unfollow 

============================================= =============================================

import os

 .....

ulink = '''curl 'https://www.instagram.com/web/friendships/''' + uid + '''/unfollow/' -X POST -H 'origin: https://www.instagram.com' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: uk,en-US;q=0.8,en;q=0.6' -H 'x-requested-with: XMLHttpRequest' -H 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Mobile Safari/537.36' -H 'cookie: mid=WFgEmgAEAAFwxSdDXrfo8AAFCuHb; datr=hapZWMkpCVayEtqUE9QZ1L_R; sessionid=IGSC13c5de61354c258b1d0a65658184b39292f3b37a6502121f2adc55f7f8477621%3ACjRnOP6jWX4XtHYSlGsnReUQfbE3Knqc%3A%7B%22_token_ver%22%3A2%2C%22_auth_user_id%22%3A'''+myid+'''%2C%22_token%22%3A%22'''+myid+'''%3Afj3xkSGeTR3houFF08iwxKCWHEWOt6bi%3Adb47725d645f676bb23b2df6de97e39f435ab84078e36fcce4b86979036aa792%22%2C%22asns%22%3A%7B%22'''+publicIp+'''%22%3A31148%2C%22time%22%3A1483005349%7D%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22last_refreshed%22%3A1483005349.437956%2C%22_platform%22%3A4%2C%22_auth_user_hash%22%3A%22%22%7D; ig_pr=1; ig_vw=1367; csrftoken=3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f; ds_user_id='''+myid+''' ' -H 'x-csrftoken: 3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f' -H 'x-instagram-ajax: 1' -H 'content-type: application/x-www-form-urlencoded' -H 'accept: */*' -H 'referer: https://www.instagram.com/'''+username+'''/following/' -H 'authority: www.instagram.com' -H 'content-length: 0' -H 'dnt: 1' --compressed'''

unfollowAndShowStatus = os.system(ulink)
print(unfollowAndShowStatus) # {"status": "ok"}0,  unfollow correctly.

====================================== =====================================
@jak: @jak:

print(r.text) # blank screen print(r.text)#黑屏

<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" class="no-js lt-ie9 lt-ie8 lt-ie7 not-logged-in "> <![endif]-->
<!--[if IE 7]>         <html lang="en" class="no-js lt-ie9 lt-ie8 not-logged-in "> <![endif]-->
<!--[if IE 8]>         <html lang="en" class="no-js lt-ie9 not-logged-in "> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" class="no-js not-logged-in "> <!--<![endif]-->
    <head><meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <title>
Instagram
</title>

        <script type="text/javascript">
  WebFontConfig = {
    custom: {
      families: ['proxima-nova:n3,n4,n6,n7'],
    }
  };
</script>
<script type="text/javascript" src="//instagramstatic-a.akamaihd.net/h1/scripts/webfont.js/c0456c81549b.js" async></script>

<style type="text/css">
  /* @license
   * MyFonts Webfont Build ID 2164953, 2012-03-23T23:06:30-0400
   *
   * The fonts listed in this notice are subject to the End User License
   * Agreement(s) entered into by the website owner. All other parties are
   * explicitly restricted from using the Licensed Webfonts(s).
   *
   * You may obtain a valid license at the URLs below.
   *
   *
   * Webfont: Proxima Nova Light by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/light/
   * Licensed pageviews: unlimited
   *
   * Webfont: Proxima Nova Regular by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/regular/
   * Licensed pageviews: unlimited
   *
   * Webfont: Proxima Nova Semibold by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/semibold/
   * Licensed pageviews: unlimited
   *
   * Webfont: Proxima Nova Bold Italic by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/bold-it/
   * Licensed pageviews: unlimited
   *
   * Webfont: Proxima Nova Bold by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/bold/
   * Licensed pageviews: unlimited
   *
   * Webfont: Proxima Nova Italic by Mark Simonson
   * URL: http://www.myfonts.com/fonts/marksimonson/proxima-nova/regular-it/
   * Licensed pageviews: unlimited
   *
   *
   * License: http://www.myfonts.com/viewlicense?type=web&buildid=2164953
   * Webfonts copyright: Copyright (c) Mark Simonson, 2005. All rights reserved.
   *
   * (c) 2012 Bitstream Inc
   */
  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.eot/115b1f7f9c04.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.eot/115b1f7f9c04.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.woff/618250d25a4d.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.ttf/646346e03084.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-bold-webfont.svg/e55a9d6051e8.svg#ProximaNovaBold') format("svg");
    font-weight: bold;
    font-style: normal; }

  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.eot/1cbb869da891.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.eot/1cbb869da891.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.woff/b1cf049474c9.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.ttf/3adb020ceae3.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-boldit-webfont.svg/29948a2d3c58.svg#ProximaNovaBoldItalic') format("svg");
    font-weight: bold;
    font-style: italic; }

  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.eot/12af77715cee.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.eot/12af77715cee.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.woff/a9a9773b8e29.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.ttf/99e19808976a.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-reg-webfont.svg/c33d2fd56309.svg#ProximaNovaRegular') format("svg");
    font-weight: normal;
    font-style: normal; }

  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.eot/1bbbd1312b0d.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.eot/1bbbd1312b0d.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.woff/9e306befca91.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.ttf/4a8663684135.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-regit-webfont.svg/876278d4b189.svg#ProximaNovaRegularItalic') format("svg");
    font-weight: normal;
    font-style: italic; }

  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.eot/5016edf79e1d.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.eot/5016edf79e1d.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.woff/615c1b06d8fa.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.ttf/2973bd483f7a.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-sbold-webfont.svg/868597833e49.svg#ProximaNovaSemibold') format("svg");
    font-weight: 600;
    font-style: normal; }
</style>

  <style type="text/css">
  @font-face {
    font-family: 'proxima-nova';
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.eot/63c84728610f.eot');
    src: url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.eot/63c84728610f.eot?#iefix') format("embedded-opentype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.woff/66bbe029f180.woff') format("woff"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.ttf/eb408516399b.ttf') format("truetype"),
      url(' //instagramstatic-a.akamaihd.net/h1/webfonts/proximanova-light-webfont.svg/858f6a9b7ef3.svg#ProximaNovaLight') format("svg");
    font-weight: 300;
    font-style: normal; }
</style>



        <meta name="robots" content="noimageindex">
        <meta name="mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta id="viewport" name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1">


        <script type="text/javascript">
        (function() {
            var docElement = document.documentElement;
            var classRE = new RegExp('(^|\\s)no-js(\\s|$)');
            var className = docElement.className;
            docElement.className = className.replace(classRE, '$1js$2');
        })();
        </script>
    <script type="text/javascript">window._timings = {"domLoading": Date.now()}</script>

                <link rel="apple-touch-icon-precomposed" sizes="76x76" href="//instagramstatic-a.akamaihd.net/h1/images/ico/apple-touch-icon-76x76-precomposed.png/932e4d9af891.png">
                <link rel="apple-touch-icon-precomposed" sizes="120x120" href="//instagramstatic-a.akamaihd.net/h1/images/ico/apple-touch-icon-120x120-precomposed.png/004705c9353f.png">
                <link rel="apple-touch-icon-precomposed" sizes="152x152" href="//instagramstatic-a.akamaihd.net/h1/images/ico/apple-touch-icon-152x152-precomposed.png/82467bc9bcce.png">
                <link rel="apple-touch-icon-precomposed" sizes="167x167" href="//instagramstatic-a.akamaihd.net/h1/images/ico/apple-touch-icon-167x167-precomposed.png/515cb4eeeeee.png">
                <link rel="apple-touch-icon-precomposed" sizes="180x180" href="//instagramstatic-a.akamaihd.net/h1/images/ico/apple-touch-icon-180x180-precomposed.png/94fd767f257b.png">
                <link rel="icon" sizes="192x192" href="//instagramstatic-a.akamaihd.net/h1/images/ico/favicon-192.png/b407fa101800.png">

            <link rel="mask-icon" href="//instagramstatic-a.akamaihd.net/h1/images/ico/favicon.svg/9d8680ab8a3c.svg" color="#262626"><link rel="shortcut icon" type="image/x-icon" href="//instagramstatic-a.akamaihd.net/h1/images/ico/favicon.ico/dfa85bb1fd63.ico">





    <link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/" hreflang="x-default" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=el" hreflang="el" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ms" hreflang="ms" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=bg" hreflang="bg" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=de" hreflang="de" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=zh-cn" hreflang="zh-cn" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=vi" hreflang="vi" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=pt" hreflang="pt" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=tl" hreflang="tl" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=tr" hreflang="tr" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ja" hreflang="ja" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ne" hreflang="ne" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=nb" hreflang="nb" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=fr" hreflang="fr" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=kn" hreflang="kn" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=sr" hreflang="sr" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=mr" hreflang="mr" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=si" hreflang="si" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=nl" hreflang="nl" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=da" hreflang="da" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=cs" hreflang="cs" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ur" hreflang="ur" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=zh-hk" hreflang="zh-hk" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=hr" hreflang="hr" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=bn" hreflang="bn" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=te" hreflang="te" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ta" hreflang="ta" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ko" hreflang="ko" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=sv" hreflang="sv" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=fr-ca" hreflang="fr-ca" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=af" hreflang="af" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=es" hreflang="es" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=hu" hreflang="hu" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=it" hreflang="it" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=sk" hreflang="sk" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=id" hreflang="id" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ru" hreflang="ru" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=fi" hreflang="fi" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=th" hreflang="th" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=gu" hreflang="gu" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ro" hreflang="ro" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=pt-br" hreflang="pt-br" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=pl" hreflang="pl" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=zh-tw" hreflang="zh-tw" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=hi" hreflang="hi" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=pa" hreflang="pa" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=ml" hreflang="ml" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=uk" hreflang="uk" />
<link rel="alternate" href="https://www.instagram.com/accounts/login/?next=/web/friendships/3533829984/unfollow/&amp;hl=en" hreflang="en" />

</head>
    <body class="">

    <span id="react-root"></span>




            <script src=//instagramstatic-a.akamaihd.net/h1/scripts/polyfills/es5-shim.min.js/6514c5e08593.js></script>
<script src=//instagramstatic-a.akamaihd.net/h1/scripts/polyfills/es5-sham.min.js/fc3c22cf2d67.js></script>
<script type="text/javascript">window._sharedData = {"entry_data": {"LoginAndSignupPage": [{}]}, "display_properties_server_guess": {"pixel_ratio": 1.5, "viewport_width": 360}, "environment_switcher_visible_server_guess": true, "qe": {"br": {"p": {}, "g": ""}, "us_li": {"p": {}, "g": ""}, "freq": {"p": {}, "g": ""}, "gql": {"p": {}, "g": ""}, "us": {"p": {"use_continue_text": "true"}, "g": "continue_vs_signup_text_test_03"}, "feed": {"p": {}, "g": ""}, "ebd": {"p": {}, "g": ""}, "activity_stories": {"p": {}, "g": ""}, "su_universe": {"p": {"can_phone": "true"}, "g": "control"}, "discovery": {"p": {}, "g": ""}, "profile": {"p": {}, "g": ""}}, "show_app_install": true, "gatekeepers": {}, "platform": "web", "language_code": "en", "config": {"viewer": null, "csrf_token": "c09xND4tYnQUZ1Vk7SwtRGxFHsTIgY4C"}, "static_root": "//instagramstatic-a.akamaihd.net/h1", "hostname": "www.instagram.com", "country_code": "UA", "activity_counts": null};</script>
<script type="text/javascript" crossorigin="anonymous" src="//instagramstatic-a.akamaihd.net/h1/bundles/en_US_Commons.js/e0324e108f49.js"></script>
<script type="text/javascript" crossorigin="anonymous" src="//instagramstatic-a.akamaihd.net/h1/bundles/en_US_LoginAndSignupPage.js/398e77eae9cf.js"></script>

<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');

fbq('init', '1425767024389221');

fbq('track', 'PageView');


</script>
<noscript>


</noscript>


            <script type="text/javascript">window._timings.domInteractive = Date.now()</script>

    </body>
</html>

I think you confused your cookies and your headers with your data . 我认为您将cookiesheadersdata混淆了。 I think you should write this as: 我认为您应该这样写:

cookies = {
    'mid': 'WFgEmgAEAAFwxSdDXrfo8AAFCuHb',
    'datr': 'hapZWMkpCVayEtqUE9QZ1L_R',
    'sessionid': 'IGSC13c5de61354c258b1d0a65658184b39292f3b37a6502121f2adc55f7f8477621%3ACjRnOP6jWX4XtHYSlGsnReUQfbE3Knqc%3A%7B%22_token_ver%22%3A2%2C%22_auth_user_id%22%3A'+myid+'%2C%22_token%22%3A%22'+myid+'%3Afj3xkSGeTR3houFF08iwxKCWHEWOt6bi%3Adb47725d645f676bb23b2df6de97e39f435ab84078e36fcce4b86979036aa792%22%2C%22asns%22%3A%7B%22'+publicIp+'%22%3A31148%2C%22time%22%3A1483005349%7D%2C%22_auth_user_backend%22%3A%22accounts.backends.CaseInsensitiveModelBackend%22%2C%22last_refreshed%22%3A1483005349.437956%2C%22_platform%22%3A4%2C%22_auth_user_hash%22%3A%22%22%7D',
    'ig_pr': '1',
    'ig_vw': '1367',
    'csrftoken': '3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f',
    'ds_user_id': myid,
}
headers = {
    'content-type': 'application/x-www-form-urlencoded',
    'origin': 'https://www.instagram.com', 
    'accept-encoding': 'gzip, deflate, br', 
    'accept-language': 'uk,en-US;q=0.8,en;q=0.6', 
    'x-requested-with': 'XMLHttpRequest',
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Mobile Safari/537.36',
    'x-csrftoken': '3jmx9MnnQ1NlU46TdGQqzpNwyBdNhi0f', 
    'x-instagram-ajax': '1', 
    'accept': '*/*', 
    'referer': 'https://www.instagram.com/1foobar/following/', 
    'authority': 'www.instagram.com', 
    'content-length': '0', 
    'dnt': '1'
}
r = requests.post('https://www.instagram.com/web/friendships/' + uid + '/unfollow/', headers=headers, cookies=cookies, data={})

What does the server return when it fails? 服务器出现故障时会返回什么? Status 200 does not mean much in this case, try looking at r.text. 在这种情况下,状态200的意义并不大,请尝试查看r.text。

Also, did you try the curl before the other library? 另外,您是否在其他磁带库之前尝试过卷曲? You didn't change the CSRF token between the two. 您没有在两者之间更改CSRF令牌。 When implemented correctly, this will be invalidated after 1 try. 正确实施后,将在1次尝试后失效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM