Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Send curl request with python

I have a cURL request I copied from the network tracking in devtools and i need to send it regularly using python.

curl "https://twitter.com/i/api/1.1/friendships/create.json" -X POST -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0" -H "Accept: */*" -H "Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate, br" -H "Content-Type: application/x-www-form-urlencoded" -H "Referer: https://twitter.com/not_doxing_myself_lol" -H "x-twitter-auth-type: OAuth2Session" -H "x-twitter-client-language: en" -H "x-twitter-active-user: yes" -H "x-csrf-token: not_doxing_myself_lol" -H "Origin: https://twitter.com" -H "Sec-Fetch-Dest: empty" -H "Sec-Fetch-Mode: cors" -H "Sec-Fetch-Site: same-origin" -H "authorization: Bearer not_doxing_myself_lol" -H "Connection: keep-alive" -H "Cookie: guest_id=v1"%"3A163657050970076789; eu_cn=1; g_state={""i_l"":1,""i_p"":1646846243191}; ct0=3e2bfe76f3316083ddf707e3f6d2ac4b152eb3dcf43826b0ba1ece6f753f06094d13fed4f9174f1e08969764643f3e437a53f0395aec99226242af669751adb744a9041981ea32ea94a5b1ca50ab0cd6; kdt=5urnpEaimZUdlLCrrmai56MkZQ3SOiLaHWdkovUw; twid=u"%"3D1267780668546826242; auth_token=not_doxing_myself_lol; night_mode=2; d_prefs=MToxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw; guest_id_ads=v1"%"3A163657050970076789; guest_id_marketing=v1"%"3A163657050970076789; personalization_id=""not_doxing_myself_lol""; dnt=1; _twitter_sess=not_doxing_myself_lol; external_referer=padhuUp37zjgzgv1mFWxJ12Ozwit7owX|0|8e8t2xd8A2w"%"3D; mbox=session#e45db1eeb1cc4444b63b2ac482ea14b5#1648982599|PC#e45db1eeb1cc4444b63b2ac482ea14b5.37_0#1712225539; at_check=true; des_opt_in=Y" --data-raw "include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&user_id=not_doxing_myself_lol"

request edited to not dox myself

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

below is the code you may refer

import requests

url = "https://twitter.com/i/api/1.1/friendships/create.json"

payload='include_profile_interstitial_type=1&include_blocking=1&include_blocked_by=1&include_followed_by=1&include_want_retweets=1&include_mute_edge=1&include_can_dm=1&include_can_media_tag=1&include_ext_has_nft_avatar=1&skip_status=1&user_id=not_doxing_myself_lol'
headers = {
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0',
  'Accept': '*/*',
  'Accept-Language': 'en-GB,en;q=0.5',
  'Accept-Encoding': 'gzip, deflate, br',
  'Content-Type': 'application/x-www-form-urlencoded',
  'Referer': 'https://twitter.com/not_doxing_myself_lol',
  'x-twitter-auth-type': 'OAuth2Session',
  'x-twitter-client-language': 'en',
  'x-twitter-active-user': 'yes',
  'x-csrf-token': 'not_doxing_myself_lol',
  'Origin': 'https://twitter.com',
  'Sec-Fetch-Dest': 'empty',
  'Sec-Fetch-Mode': 'cors',
  'Sec-Fetch-Site': 'same-origin',
  'authorization': 'Bearer not_doxing_myself_lol',
  'Connection': 'keep-alive',
  'Cookie': 'guest_id=v1%3A163657050970076789; eu_cn=1; g_state={i_l:1,i_p:1646846243191}; ct0=3e2bfe76f3316083ddf707e3f6d2ac4b152eb3dcf43826b0ba1ece6f753f06094d13fed4f9174f1e08969764643f3e437a53f0395aec99226242af669751adb744a9041981ea32ea94a5b1ca50ab0cd6; kdt=5urnpEaimZUdlLCrrmai56MkZQ3SOiLaHWdkovUw; twid=u%3D1267780668546826242; auth_token=not_doxing_myself_lol; night_mode=2; d_prefs=MToxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw; guest_id_ads=v1%3A163657050970076789; guest_id_marketing=v1%3A163657050970076789; personalization_id=not_doxing_myself_lol; dnt=1; _twitter_sess=not_doxing_myself_lol; external_referer=padhuUp37zjgzgv1mFWxJ12Ozwit7owX|0|8e8t2xd8A2w%3D; mbox=session#e45db1eeb1cc4444b63b2ac482ea14b5#1648982599|PC#e45db1eeb1cc4444b63b2ac482ea14b5.37_0#1712225539; at_check=true; des_opt_in=Y'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading