MCPcopy Index your code
hub / github.com/f4rih/twpy

github.com/f4rih/twpy @1.2.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.2.5 ↗ · + Follow
44 symbols 121 edges 15 files 27 documented · 61%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Twpy

image image

Twitter High level scraper for humans.

Features

  • NO LIMIT, NO API required
  • Fast and easy to use
  • Working with python 3.5+
  • Integrated with pandas for data science research

Installation

Manual install via git :

$ git clone https://github.com/0x0ptim0us/twpy.git
$ cd twpy
$ python setup.py install

Install using pip:

$ pip install twpy
# or
$ python -m pip install twpy

Usage

Create Twpy object :

from twpy import TwpyClient 

# create twpy client object
tc = TwpyClient()

with proxy :

# or you can pass proxy
tc = TwpyClient(proxy="127.0.0.1:8080")

Get twpy current version :

tc.__version__
# '1.2.4'

Get user followers:

# get user followers, limited up to 50
# interval : delay between each request, default is 0 for no delay
# proxy : send traffic through proxy, default is none
followers_data = tc.get_followers(username="elonmusk", limit=50, interval=1)

Get user timeline:

tweets = tc.get_timeline(username="elonmusk", limit=50)

Get user profile:

user_info = tc.get_user(username="elonmusk")

Convert result object to other data structures :

from twpy.serializers import to_pandas, to_json, to_list
# convert result to pandas data frame, json and list
# pandas
pandas_sample = to_pandas(followers_data)
# json
json_sample = to_json(followers_data)
# list
list_sample = to_list(followers_data)

Search example:

# search user tweets until 2015
tweets = tc.search(username="elonmusk", until="2015")

# add limit and interval
tweets = tc.search(username="elonmusk", until="2015", limit=100, interval=1)

# search tweets contains `love` word
tweets = tc.search(query="love", limit=100, interval=1)

# search tweets which contains `love` word and were tweeted since 2015-01-01
tweets = tc.search(query="love", since="2015-01-01", limit=10)

# Supported methods | method | description | |--|--| | get_friends() | get user followings/friends | | get_timeline() | get user timeline/tweets | | get_user() | get user profile info | | search() | search tweets with query and username |

Meta

Fardin Allahverdinazhand - \@0x0ptim0us - 0x0ptim0us@gmail.com Distributed under the MIT license. see LICENSE.txt for more information.

https://github.com/0x0ptim0us/twpy

Core symbols most depended-on inside this repo

get
called by 10
twpy/core/request.py
to_json
called by 3
twpy/serializers/__to_json.py
extract_timeline_cursor
called by 2
twpy/utils/__init__.py
extract_timeline
called by 2
twpy/utils/__init__.py
follower_following
called by 2
twpy/core/grabber.py
read_file
called by 1
setup.py
header_maker
called by 1
twpy/utils/__init__.py
extract_cursor
called by 1
twpy/utils/__init__.py

Shape

Method 19
Function 15
Class 10

Languages

Python100%

Modules by API surface

twpy/exceptions/__init__.py10 symbols
twpy/__init__.py9 symbols
twpy/utils/__init__.py6 symbols
twpy/models/data_model.py6 symbols
twpy/core/grabber.py5 symbols
twpy/core/request.py4 symbols
twpy/serializers/__to_pandas.py1 symbols
twpy/serializers/__to_list.py1 symbols
twpy/serializers/__to_json.py1 symbols
setup.py1 symbols

For agents

$ claude mcp add twpy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact