How to Scrape X (Twitter) in 2026 Without the Official API (Python)
Автор: Luke A
Загружено: 2026-10-24
Просмотров: 411
Описание:
One of levelsio's tweets got 4,748 likes and 7,506 saves: more people saved it than liked it. This video shows why the usual free tools for scraping X (snscrape and Tweepy) don't work any more, then builds a 28-line Python script that pulls every tweet from any public X account with its views, likes and saves, uses X's own search operators to find anyone's best tweets ever, and uses pandas to find what people actually save. Not a coder? The free X search builder below writes the query for you, no signup.
Try the same request in the Playground: https://app.socialfetch.dev/playgroun...
Get an API key with 100 free credits (no card): https://www.socialfetch.dev/?utm_sour...
Free X search query builder (no signup): https://www.socialfetch.dev/tools/twi...
X (Twitter) API reference: https://www.socialfetch.dev/docs/api/...
Free X profile viewer (no code): https://www.socialfetch.dev/tools/twi...
Run it:
1. pip install requests pandas
2. Set your key: export SOCIALFETCH_API_KEY=your_key (Windows PowerShell: $env:SOCIALFETCH_API_KEY="your_key")
3. python scrape_x.py (change levelsio to any public account)
4. python analyze.py (reads the tweets.csv from step 3)
scrape_x.py (every tweet from an account, to CSV):
import csv, os, requests
API = "https://api.socialfetch.dev/v1/twitter"
HEADERS = {"x-api-key": os.environ["SOCIALFETCH_API_KEY"]}
def get(path, **params):
r = requests.get(API + path, headers=HEADERS, params=params)
r.raise_for_status()
return r.json()["data"]
1. Every tweet from one account, ten pages
tweets, cursor = [], None
for _ in range(10):
page = get("/profiles/levelsio/tweets", cursor=cursor)
tweets += [t for t in page["tweets"] if not t["isRetweet"]]
cursor = page["page"]["nextCursor"]
if not cursor:
break
2. Save them
with open("tweets.csv", "w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow(["text", "views", "likes", "bookmarks", "replies", "url"])
for t in tweets:
m = t["metrics"]
w.writerow([t["text"], m["views"], m["likes"], m["bookmarkCount"], m["replies"], t["url"]])
print(f"{len(tweets)} tweets saved to tweets.csv")
search_x.py (X's search operators):
import os, requests
r = requests.get(
"https://api.socialfetch.dev/v1/twitte...",
headers={"x-api-key": os.environ["SOCIALFETCH_API_KEY"]},
params={"query": "from:levelsio min_faves:3000", "section": "top"},
)
r.raise_for_status()
for t in r.json()["data"]["tweets"]:
m = t["metrics"]
text = " ".join(t["text"].split())
print(f"{m['likes']:6} likes {m['bookmarkCount']:6} saves {text[:44]}")
analyze.py (what people save; pip install pandas):
import pandas as pd
df = pd.read_csv("tweets.csv")
df = df[df["views"].ge(10_000)]
df["saves_per_1k"] = (df["bookmarks"] / df["views"] * 1000).round(1)
top = df.sort_values("saves_per_1k", ascending=False).head(5)
for _, t in top.iterrows():
text = " ".join(t["text"].split())
print(f"{t['saves_per_1k']:5} {t['likes']:6} likes {t['bookmarks']:5} saves {text[:40]}")
This reads public posts only, the same ones you'd see in a browser. What you do with them is still up to X's rules: read X's Terms of Service and Developer Agreement before you build something commercial.
Sources: snscrape issue #996 (https://github.com/JustAnotherArchivi...) and X's API pricing page (https://docs.x.com/x-api/getting-star..., both read 24 Oct 2026. Every number in the video is from real runs that day.
Chapters
0:00 More saves than likes
0:31 Why the old free tools fail
1:22 One key instead
1:56 Every tweet from an account
2:38 Search with X's own operators
3:13 What people actually save
3:59 Use it on your niche
4:28 What to try next
I'm Luke, the founder of Social Fetch. The voiceover uses an AI clone of my own voice.
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: