Requests ile sosyal medyalarda paylaşım yapma kodlarına yıllardan beri merakım vardı.
Hazir yapay zeka gelişmiş iken yapay zekaya bunun kodlarını yaptırayım dedim.
Yaptıracağım kodları kullanmayacağım. Session cookie sistemleri güvenli olmadığını hesapların banlanacağını biliyorum. Tamamiyle meraktan kurcalıyorum. Normal seviyede python bilgim var.
Aldığım hata
Hata oluştu: 401
{"resource_response":{"error":{"status":"failure","http_status":401,"code":3,"message":"Authorization failed.","api_error_code":3,"extra_data":{"message":"None"}},"data":null},"client_context":{"analysis_ua":{"app_type":5,"app_version":"","browser_name":"Chrome","browser_version":"120.0.0","device_type":null,"device":"Other","os_name":"Windows 10","os_version":"10"},"app_type_detailed":5,"app_version":"c6ca963","autologin":null,"batch_exp":true,"browser_locale":"en-US","browser_name":"Chrome","browser_type":1,"browser_version":"120.0.0","country":"TR","country_from_hostname":"US","country_from_ip":"TR","csp_nonce":"ed91f50977d5c7710af3dc766ae2b145","current_url":"https://www.pinterest.com/resource/PinResource/create/","debug":false,"deep_link":"","enabled_advertiser_countries":["AR","AT","AU","BE","BR","CA","CH","CL","CO","DE","DK","ES","FI","FR","GB","IE","IT","JP","LU","MX","NL","NO","NZ","PT","SE","US"],"facebook_token":null,"full_path":"/resource/PinResource/create/","http_referrer":"https://www.pinterest.com/","impersonator_user_id":null,"invite_code":"","invite_sender_id":"","is_authenticated":false,"is_bad_bot":false,"is_bot":"false","is_perf_metrics_bot":false,"is_vpn":false,"is_full_page":false,"is_mobile_agent":false,"is_sterling_on_steroids":false,"is_tablet_agent":false,"language":"en","locale":"en-US","origin":"https://www.pinterest.com","path":"/resource/PinResource/create/","placed_experiences":null,"referrer":null,"region_from_ip":"34","request_host":"www.pinterest.com","request_identifier":"1843741243740861","social_bot":"","stage":"prod","sterling_on_steroids_ldap":null,"sterling_on_steroids_user_type":null,"theme":"light","unauth_id":"196f4357a46143089de28aa2d7e0d2a5","seo_debug":false,"user_agent_can_use_native_app":false,"user_agent_platform":"other","user_agent_platform_version":null,"user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","user":{"unauth_id":"196f4357a46143089de28aa2d7e0d2a5","ip_country":"TR","ip_region":"34"},"utm_campaign":null,"visible_url":"/"},"resource":{"name":"PinResource","options":{"bookmarks":["-end-"],"board_id":"817262732319760010","image_url":"https://i.nefisyemektarifleri.com/2026/04/23/hatay-usulu-kisir-tarifi.jpg","description":"Hatay Usulü Kısır Tarifi (Videolu)","link":"https://www.nefisyemektarifleri.com/hatay-usulu-kisir-tarifi-videolu-12500592/","title":"Hatay Usulü Kısır Tarifi (Videolu)"}},"request_identifier":"1843741243740861"}from curl_cffi import requests # Standart requests değil, curl_cffi olanı kullanmalısın
import json
def pin_paylas():
# 1. Ayarlar
# Not: pinterest_sess çok uzun olduğu için burada kısalttım, sen kendi tam kodunu buraya koy.
cookies = {
'pinterest_sess': 'SENİN_UZUN_SESS_KODUN',
'csrftoken': 'c4121cf7fd37e8360ead1cdbea6fa221'
}
headers = {
'x-csrftoken': cookies['csrftoken'],
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'referer': 'https://www.pinterest.com/',
'x-requested-with': 'XMLHttpRequest',
}
# 2. Pin Bilgileri
payload = {
"options": {
"board_id": "817262732319760010",
"image_url": "https://i.nefisyemektarifleri.com/2026/04/23/hatay-usulu-kisir-tarifi.jpg",
"description": "Hatay Usulü Kısır Tarifi",
"link": "https://www.nefisyemektarifleri.com/",
"title": "Nefis Kısır"
}
}
data = {
'source_url': '/',
'data': json.dumps(payload),
}
# 3. İstek Gönderme
print("İstek gönderiliyor...")
try:
response = requests.post(
'https://www.pinterest.com/resource/PinResource/create/',
headers=headers,
cookies=cookies,
data=data,
impersonate="chrome120"
)
# 4. Sonucu Yazdırma
print(f"Durum Kodu: {response.status_code}")
if response.status_code == 200:
print("Başarılı! Pin paylaşıldı.")
print(response.json())
else:
print("Hata mesajı:")
print(response.text)
except Exception as e:
print(f"Bağlantı hatası: {e}")
# --- ÇOK ÖNEMLİ: Fonksiyonu burada çalıştırıyoruz ---
if __name__ == "__main__":
pin_paylas()