Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
snscrape
#1
I'm new to Python. I am trying the snscrape method to scan tweets and save them in tabular format. The code I found from a site works. Here my code:

import pandas as pd
from tqdm.notebook import tqdm
import snscrape.modules.twitter as sntwitter

scraper = sntwitter.TwitterSearchScraper("#yağma")

tweets = []
n_tweets = 50

for i, tweet in tqdm(enumerate(scraper.get_items()), total = n_tweets):
    data=[tweet.date, tweet.id, tweet.content, tweet.user.username, tweet.likeCount, tweet.retweetCount]
        
    tweets.append(data)
    if i>n_tweets:
        break
        
        
tweet_df = pd.DataFrame(
    tweets, columns=["date", "id", "content", "username", "like_count", "retweet_count"]
)
tweet_df
But there are some problems:
  1. 1- When I download tweets in xls format, the content of the tweets is limited to 40 characters, I can't see all the content
    2- I can't set language and region for tweets
    3- When there are too many lines, I separate them with three dots and I can only download a limited number of lines. For example:
    1. 1.line: tweet date- content
      2.line tweet date2-content2
      ...... (i cannot see or download these lines)
      1001.line tweetdate1001-content1001
How can I solve these problems
Larz60+ write Mar-12-2023, 07:38 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed for you this time. Please use BBCode tags on future posts.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020