Requests POST isteği

Merhaba,
Burp ile yakaladığım bu isteği

POST /gql HTTP/1.1
Host: gql.twitch.tv
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
Accept: */*
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Referer: https://www.twitch.tv/
Authorization: undefined
Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko
Content-Type: text/plain; charset=UTF-8
Device-Id: NtXpW8epoqljzbWnqhgSEuLkKXK1TEfe
Origin: https://www.twitch.tv
Content-Length: 665
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
Pragma: no-cache
Cache-Control: no-cache
Te: trailers
Connection: close

{"operationName":"PlaybackAccessToken_Template",
"query":
"query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) {  streamPlaybackAccessToken(channelName: $login, params: {platform: \"web\", playerBackend: \"mediaplayer\", playerType: $playerType}) @include(if: $isLive) {    value    signature    __typename  }  videoPlaybackAccessToken(id: $vodID, params: {platform: \"web\", playerBackend: \"mediaplayer\", playerType: $playerType}) @include(if: $isVod) {    value    signature    __typename  }}",
"variables":{
"isLive":true,
"login":"tingirifistik",
"isVod":false,
"vodID":"",
"playerType":"site"}}

nasıl requests kütüphanesi ile post isteği olarak gönderebilirim?

import requests

data = {"operationName":"PlaybackAccessToken_Template","query":"query PlaybackAccessToken_Template($login: String!, $isLive: Boolean!, $vodID: ID!, $isVod: Boolean!, $playerType: String!) {  streamPlaybackAccessToken(channelName: $login, params: {platform: \"web\", playerBackend: \"mediaplayer\", playerType: $playerType}) @include(if: $isLive) {    value    signature    __typename  }  videoPlaybackAccessToken(id: $vodID, params: {platform: \"web\", playerBackend: \"mediaplayer\", playerType: $playerType}) @include(if: $isVod) {    value    signature    __typename  }}","variables":{"isLive":True,"login":"tingirisssdfistik","isVod":False,"vodID":"","playerType":"site"}}

header = {
"Host": "gql.twitch.tv",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0",
"Accept": "*/*",
"Accept-Language": "en-US",
"Accept-Encoding": "gzip, deflate",
"Referer": "https://www.twitch.tv/",
"Authorization": "undefined",
"Client-Id": "kimne78kx3ncx6brgo4mv6wki5h1ko",
"Content-Type": "text/plain; charset=UTF-8",
"Device-Id": "NtXpW8epoqljzbWnqhgSEuLkKXK1TEfe",
"Origin": "https://www.twitch.tv",
"Content-Length": "665",
"Dnt": "1",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"Te": "trailers",
"Connection": "close"
}

a = requests.post("https://gql.twitch.tv/gql", data=data, headers=header)
print(a.status_code)

Bu kodu denedim ama olmadı.

Buraya baktınızmı ?

1 Beğeni

Istegi HTTP’ye cevirip ncat gibi bir programa yaparak veya bilgisayardan cikan paketleri yakalayarak inceleyebilirsin:

a = requests.post("http://127.0.0.1:1234/gql", data=data, headers=header)
POST /gql HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Host: gql.twitch.tv
Accept-Language: en-US
Referer: https://www.twitch.tv/
Authorization: undefined
Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko
Content-Type: text/plain; charset=UTF-8
Device-Id: NtXpW8epoqljzbWnqhgSEuLkKXK1TEfe
Origin: https://www.twitch.tv
Content-Length: 782
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-site
Pragma: no-cache
Cache-Control: no-cache
Te: trailers

operationName=PlaybackAccessToken_Template&query=query+PlaybackAccessToken_Template%28%24login%3A+String%21%2C+%24isLive%3A+Boolean%21%2C+%24vodID%3A+ID%21%2C+%24isVod%3A+Boolean%21%2C+%24playerType%3A+String%21%29+%7B++streamPlaybackAccessToken%28channelName%3A+%24login%2C+params%3A+%7Bplatform%3A+%22web%22%2C+playerBackend%3A+%22mediaplayer%22%2C+playerType%3A+%24playerType%7D%29+%40include%28if%3A+%24isLive%29+%7B++++value++++signature++++__typename++%7D++videoPlaybackAccessToken%28id%3A+%24vodID%2C+params%3A+%7Bplatform%3A+%22web%22%2C+playerBackend%3A+%22mediaplayer%22%2C+playerType%3A+%24playerType%7D%29+%40include%28if%3A+%24isVod%29+%7B++++value++++signature++++__typename++%7D%7D&variables=isLive&variables=login&variables=isVod&variables=vodID&variables=playerType

data'nin JSON olarak gitmesi gerekiyor.

1 Beğeni

Teşekkürler, işe yaradı

Bazen başka sitelerde datayı json olarak göndermeyince de kabul ediyor, bunun bir nedeni var mı?

Cunku JSON’dan baska data formatlari da var.