Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 1 #769

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,48 @@ If you want to use the development version:
pip3 install git+https://github.com/JustAnotherArchivist/snscrape.git

## Usage

### Python

#### Using the Twitter API
A simple way to get around using scraping tweets using the twitter module

```python

import snscrape.modules.twitter as sntwitter
import pandas as pd

query = '#python' # a query string , for specific user tweets, you could use 'from:<username>'
scraper = sntwitter.TwitterSearchScraper(query)
tweets_list = []



for tweet in scraper.get_items():
data = [

tweet.id,
tweet.date,
tweet.content,
tweet.user.username,
tweet.likeCount,
tweet.retweetCount,

]

tweets_list.append(data)


column_names = [ 'ID','Date','Content', 'Username', 'LikeCount','RetweetCount']

# converting to a dataframe using pandas
frame = pd.DataFrame(data = tweets_list, columns = column_names)
frame.to_csv('./python_hashtag_tweets.csv', index = False)

```



### CLI
The generic syntax of snscrape's CLI is:

Expand Down