I need help with scraping data from Twitter using ScraperAPI for my project on sentiment analysis of electric vehicles. I requested 10 tweets and managed to get the tweets using the code below. However, the tweets(snippet) in the output are truncated. Is there a way to get the entire tweet?
Has anyone else encountered this issue? Any suggestions would be really helpful. Thank you!
Here’s the code I used:
import requests
import pandas as pd
twitter_data = []
payload = {
‘api_key’: ‘ ‘, # I inserted my API key here
‘query’: ‘electric vehicle’,
‘num’: ’10’
}
response = requests.get(‘https://api.scraperapi.com/structured/twitter/search’, params=payload)
data = response.json()
print(data)
OUTPUT: # I have removed two headers from each section of the output that highlight links.
{
“search_information”: {“query_displayed”: “site:twitter.com “electric vehicle””},
“organic_results”: [
{
“position”: 0,
“title”: “Felix Hamer • electricfelix”,
“snippet”: “The Slowdown in US Electric Vehicle Sales Looks More Like a Blip by @tsrandall “And for all the talk of an EV slowdown, many longer-term…”,
“highlights”: [“Electric Vehicle”]
},
{
“position”: 1,
“title”: “energy star – X.com”,
“snippet”: “Making the switch to an electric vehicle is not only good for the planet, it could also save you $1400/year on fuel and car maintenance.”,
“highlights”: [“electric vehicle”]
},
{
“position”: 2,
“title”: “Electric Vehicle Association (@ev_association) / X”,
“snippet”: “We are a network of Electric Vehicle advocates, 100% volunteer led, and represent over 100 chapters and thousands of members across North America. Automotive”,
“highlights”: [“Electric Vehicle”]
},
{
“position”: 3,
“title”: “US Department of Energy”,
“snippet”: “HOP IN! New electric vehicle charging stations are popping up everywhere, making it easier than ever to power up and ride.”,
“highlights”: [“electric vehicle”]
},
{
“position”: 4,
“title”: “Big_Orrin”,
“snippet”: “So electric vehicle operating costs continue to use vs ICEs. Price paid per mile the same as ICE cars but ICE cars see their fuel prices…”,
“highlights”: [“electric vehicle”]
},
{
“position”: 5,
“title”: “Is the Electric Cars Revolution Losing Momentum?”,
“snippet”: “An electric vehicle is probably only suitable for individuals who have a designated area for charging at their homes. Globally, China has…”,
“highlights”: [“electric vehicle”]
},
{
“position”: 6,
“title”: “Chase Cain”,
“snippet”: “Electric vehicle charging isn’t keeping up, frustrating EV drivers ⚡️ according to new report from. @JDPowerAutos.”,
“highlights”: [“Electric vehicle”]
},
{
“position”: 7,
“title”: “Route Fifty”,
“snippet”: “People who live closer to public electric vehicle chargers view the cars more positively, even when accounting for people’s party…”,
“highlights”: [“electric vehicle”]
},
{
“position”: 8,
“title”: “nyserda”,
“snippet”: “Sunday Read: Electric vehicle fast chargers are growing strongly in the United States with one EV fast charging station for every 15 gas…”,
“highlights”: [“Electric vehicle”]
},
{
“position”: 9,
“title”: “ICF”,
“snippet”: “The electric vehicle market in the U.S. is growing rapidly, yet EVs are still considered inaccessible to many due to their high upfront cost.”,
“highlights”: [“electric vehicle”]
}
],
“pagination”: {
“load_more_url”: “http://api.scraperapi.com/?url=https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dsite%3Atwitter.com%2B%2522electric%2Bvehicle%2522%26sca_esv%3Da24d50f4328fb081%26gl%3DUS%26ei%3DUDBXZpXaONK9kPIP_6eTSA%26start%3D10%26sa%3DN&autoparse=true”,
“pages_count”: 1
}
}
Glare07 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.