Library Python powerful untuk scraping Twitter/X menggunakan Selenium. Ekstrak tweet berdasarkan keyword, tanggal, bahasa dengan mudah.
pip install panen-tweet
pip install panen-tweet
git clone https://github.com/Dhaniaaa/panen-tweet.git cd panen-tweet pip install -e .
# 1. Install library !pip install panen-tweet # 2. Install Google Chrome !panen-tweet install-chrome
Sebelum menggunakan, Anda perlu mendapatkan auth_token dari akun Twitter/X Anda:
Buka x.com dan login menggunakan browser
Tekan F12 untuk membuka Developer Tools
Pilih tab Application (Chrome) atau Storage (Firefox)
Expand Cookies → klik https://x.com
Cari cookie auth_token dan salin
nilainya
Kemanan privasi Anda adalah prioritas kami.
panen-tweet
Program akan meminta: auth_token, keyword, jumlah tweet, tanggal, bahasa, dan jenis tweet.
from panen_tweet import TwitterScraper import datetime, os # Setup auth_token = os.getenv('TWITTER_AUTH_TOKEN') # Inisialisasi scraper scraper = TwitterScraper( auth_token=auth_token, scroll_pause_time=5, headless=True ) # Scraping df = scraper.scrape_with_date_range( keyword="python programming", target_per_session=100, start_date=datetime.datetime(2024, 1, 1), end_date=datetime.datetime(2024, 1, 7), interval_days=1, lang='en', search_type='latest' ) # Simpan hasil if df is not None: scraper.save_to_csv(df, "hasil.csv")
💡 Recommended untuk security - simpan token di environment variable
$env:TWITTER_AUTH_TOKEN = "token" panen-tweet
export TWITTER_AUTH_TOKEN="token" panen-tweet
Data yang dihasilkan dalam format CSV dengan kolom:
username
handle
timestamp
tweet_text
url
reply_count
retweet_count
like_count
| Parameter | Tipe | Default | Deskripsi |
|---|---|---|---|
auth_token |
string | None | Cookie auth_token (WAJIB) |
scroll_pause_time |
int | 5 | Jeda antar scroll (detik) |
headless |
bool | True | True = tanpa GUI |
| Parameter | Deskripsi |
|---|---|
keyword |
Kata kunci pencarian (WAJIB) |
target_per_session |
Jumlah target tweet per sesi |
start_date / end_date |
Rentang tanggal (WAJIB) |
interval_days |
Interval hari per sesi (1 = per hari) |
lang |
Kode bahasa: 'id', 'en', 'ja', dll |
search_type |
'top' atau 'latest' |
id - Indonesia
en - English
ja - Japanese
es - Spanish
fr - French
Package otomatis download ChromeDriver. Pastikan Chrome terinstall.
Install sekarang dan mulai scraping data tweet