Skip to main content

A lightweight library for scraping Twitter data.

Project description

Tweezers

Lightweight Python library for scraping data via the Twitter search API.

from tweezers import Tweezers

Create an instance of Tweezers with API credentials

# Loading Twitter auth credentials from a local JSON file. Get yours here:
# https://developer.twitter.com/en/apps/
import json
import os

fp = os.path.join(os.getcwd(), "credentials.json")
with open(fp) as f:
    credentials = json.load(f)

t = Tweezers(
    api_key=credentials["api_key"],
    api_secret_key=credentials["api_secret_key"],
    access_token=credentials["access_token"],
    access_token_secret=credentials["access_token_secret"]
)

Perform a search

Searching returns an instance of a class TweezerSearch, which contains various data attributes returned by the Twitter API:

s = t.search(search_term="bitcoin", total=1000, result_type="recent")
# All the tweet results are returned in a Pandas DataFrame:
s.results_df.head()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tweezers-0.0.2.tar.gz (10.7 kB view hashes)

Uploaded Source

Built Distribution

tweezers-0.0.2-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page