How to Add Social Media Icons to an Email Signature
Enhance your email signature by adding social media icons. Discover step-by-step instructions to turn every email into a powerful marketing tool.

Scraping tweets from X (formerly Twitter) using Python unlocks a goldmine of real-time data for market research, sentiment analysis, and content strategy. This guide breaks down exactly how to pull public tweet data into a format you can actually use, walking you through every step from setting up your environment to exporting your findings to a CSV file.
Before writing a single line of code, it’s worth understanding why this is such a powerful technique for marketers, brand managers, and content creators. Raw data from X gives you a direct, unfiltered look into public conversations. You can use it to:
In short, scraping tweets moves you from guessing what your audience wants to know to understanding what they’re actively talking about.
Things have changed on X. The once easily-accessible free API is now far more restrictive, making official access for large-scale data collection a costly endeavor. This has led many to use scraping libraries that access the same publicly available information you can see in a web browser, just programmatically.
When you're doing this, always remember to be a good digital citizen:
With that ground rule set, let's get into the technical side of things.
To pull this off, we'll use a fantastic Python library called snscrape. It's a scraper for social networking services that is particularly effective for pulling historical and recent public data from platforms like X without needing official API keys. It’s a great starting point for anyone new to data collection.
We'll also use pandas, the go-to library in Python for data manipulation and analysis. It allows us to neatly organize the scraped data into a structured format, like a spreadsheet, ready for you to analyze Twitter data, and easily save it to a file.
First, you need to get your computer ready. This involves installing Python and the necessary libraries. If you already have Python set up, you can skip to installing the libraries.
We’ll use pip, Python's package manager, to install snscrape and pandas. It’s highly recommended to do this within a virtual environment to keep your project dependencies separate from your system's Python installation.
On macOS/Linux:
python3 -m venv twitter-scraper
source twitter-scraper/bin/activate
On Windows:
python -m venv twitter-scraper
.\\twitter-scraper\\Scripts\\activate
Now, with your environment active, run this command in your terminal:
pip install snscrape pandas
This command downloads and installs the versions of snscrape and pandas we need. You’re now ready to start scraping.
Let's start with a simple script. Our goal is to scrape the 10 most recent tweets that contain the hashtag "#SocialMediaMarketing". Create a new Python file (e.g., scraper.py) and add the following code:
import snscrape.modules.twitter as sntwitter
import pandas as pd
# Define the search query and the number of tweets to scrape
query = "#SocialMediaMarketing"
limit = 10
tweets = []
# Use the TwitterSearchScraper to get the tweets
for tweet in sntwitter.TwitterSearchScraper(query).get_items():
if len(tweets) == limit:
break
else:
tweets.append([tweet.date, tweet.user.username, tweet.rawContent])
# Create a DataFrame from the tweets list
df = pd.DataFrame(tweets, columns=['Date', 'User', 'Tweet'])
# Print the DataFrame to see the results
print(df)
Let's review what this script does:
snscrape and pandas.#SocialMediaMarketing) and a limit of 10 tweets.tweets to store our data.for loop iterates through the results from sntwitter.TwitterSearchScraper(query).get_items(). This is the part that does the actual scraping.Run this script from your terminal (python scraper.py), and you should see the 10 most recent tweets related to social media marketing neatly printed out!
A simple keyword search is just the beginning. The real power comes from using X's advanced search operators within your snscrape query string. This lets you drill down to find exactly the information you need.
Here are some of the most useful operators for marketers:
Want to see what a competitor or industry leader has been tweeting about?
query = "from:postbase"
Find public replies directed at a particular account.
query = "to:garyvee"
This is extremely useful for analyzing sentiment during a specific campaign or event.
query = "#productlaunch since:2023-10-01 until:2023-10-31"
Now, let's put it all together. Imagine you want to find all tweets from a specific marketing influencer about "AI" since the start of the year that received at least 50 likes.
query = "(from:username) AI since:2024-01-01 min_faves:50"
A handful of other useful operators include:
min_retweets:10 (tweets with at least 10 retweets)min_replies:5 (tweets with at least 5 replies)lang:en (tweets in English)Experiment by swapping these into your query variable to see how much control you have over the data you collect.
Printing data to the console is fine for a quick test, but it's not practical for analysis. The final step is to refine our script to collect a wider range of data points and save everything to a CSV file, which you can then open in Excel or Google Sheets.
Here’s the complete, final script that pulls more information (like replies, retweets, and likes) and saves it neatly.
import snscrape.modules.twitter as sntwitter
import pandas as pd
import time
# Create a list to store tweets
tweets_list = []
# Define search query and number of tweets to fetch
# Let's find tweets about 'content strategy' from the past year
query = "content strategy since:2023-01-01"
limit = 500
print(f"Starting to scrape for '{query}'...")
# Use TwitterSearchScraper to get our tweets
for i, tweet in enumerate(sntwitter.TwitterSearchScraper(query).get_items()):
if i >,= limit:
break
# Appending relevant information
tweets_list.append([
tweet.date,
tweet.id,
tweet.rawContent,
tweet.user.username,
tweet.likeCount,
tweet.retweetCount,
tweet.replyCount,
tweet.lang,
tweet.sourceLabel,
tweet.url
])
# Simple progress indicator
if (i+1) % 50 == 0:
print(f"Scraped {i+1} tweets...")
# Creating a DataFrame from the tweets list above
tweets_df = pd.DataFrame(tweets_list, columns=[
'Datetime',
'Tweet Id',
'Text',
'Username',
'Likes',
'Retweets',
'Replies',
'Language',
'Source',
'URL'
])
# Saving the DataFrame to a CSV file
file_name = "content_strategy_tweets.csv"
tweets_df.to_csv(file_name, sep=',', index=False)
print(f"\nScraping finished! Data saved to {file_name}.")
When you run this code, it will:
content_strategy_tweets.csv in the same directory as your script.You now have a structured dataset ready for analysis. You can sort it by the number of likes to find the most popular content ideas, filter it by keywords to gauge sentiment, or identify influential users in the conversation.
Scraping public tweets with Python and snscrape is an accessible yet powerful way to gather real-time data for market research and content strategy inspiration. By using advanced search operators and organizing the output with pandas, you transform raw conversation into structured, actionable insights that can give you a genuine competitive edge.
Of course, collecting the data is just the beginning. The real work starts when you turn those insights into compelling content and manage its delivery across all your platforms. That’s an area we found particularly chaotic and frustrating, which is why we built Postbase. We designed it to be a clean, modern hub for social media management, focusing on today's reality of short-form video and multi-platform scheduling, without the clunky interfaces of older tools. Once you have your content ideas from your scraped data, our visual calendar and reliable scheduling help you execute that strategy flawlessly.
Enhance your email signature by adding social media icons. Discover step-by-step instructions to turn every email into a powerful marketing tool.
Record clear audio for Instagram Reels with this guide. Learn actionable steps to create professional-sounding audio, using just your phone or upgraded gear.
Check your Instagram profile interactions to see what your audience loves. Discover where to find these insights and use them to make smarter content decisions.
Requesting an Instagram username? Learn strategies from trademark claims to negotiation for securing your ideal handle. Get the steps to boost your brand today!
Attract your ideal audience on Instagram with our guide. Discover steps to define, find, and engage followers who buy and believe in your brand.
Activate Instagram Insights to boost your content strategy. Learn how to turn it on, what to analyze, and use data to grow your account effectively.
Wrestling with social media? It doesn’t have to be this hard. Plan your content, schedule posts, respond to comments, and analyze performance — all in one simple, easy-to-use tool.