Twitter X-Client-Transaction-Id generator written in python.
Maintained. Last release 5 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and issue handling.
$
pip install xclienttransactionX-Client-Transaction-ID
Twitter X-Client-Transaction-Id generator written in python.
Reference :
- Twitter Header: Part 1, Deobfuscation
- Twitter Header: Part 2, Reverse Engineering
- Twitter Header: Part 3, Generating the header
Installation
Install XClientTransaction with pip
pip install XClientTransaction -U --no-cache-dir
Usage/Examples
python quickstart.py
Get x.com Home Page and ondemand.s File Response
Synchronous Version
import bs4
import requests
from x_client_transaction.utils import generate_headers, handle_x_migration, get_ondemand_file_url
# INITIALIZE SESSION
session = requests.Session()
session.headers = generate_headers()
# GET HOME PAGE RESPONSE
# required only when hitting twitter.com but not x.com
# returns bs4.BeautifulSoup object
home_page_response = handle_x_migration(session=session)
# for x.com no migration is required, just simply do
home_page = session.get(url="https://x.com/home")
home_page_response = bs4.BeautifulSoup(home_page.content, 'html.parser')
# GET ondemand.s FILE RESPONSE
ondemand_file_url = get_ondemand_file_url(response=home_page_response)
ondemand_file = session.get(url=ondemand_file_url)
ondemand_file_response = bs4.BeautifulSoup(ondemand_file.content, 'html.parser')
# Getting "Couldn't get KEY_BYTE indices" error? Try passing the original response or the response text
# both should work
# ondemand_file_response = ondemand_file
ondemand_file_response = ondemand_file.text