Thanks to visit codestin.com
Credit goes to github.com

Skip to content

toby-p/tweezers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages