JustAnotherArchivist / snscrape

A social networking service scraper in Python
GNU General Public License v3.0
4.52k stars 712 forks source link

tweet.retweetcount return null #911

Closed ihabpalamino closed 1 year ago

ihabpalamino commented 1 year ago

Describe the bug

while scraping informations all informations are scrapped successfully but tweet.retweetcount it returns null here is my code

import os
import sys
import snscrape.modules.twitter as sntwitter
import pandas as pd
import json

Username = sys.argv[1]
SINCE = sys.argv[2]
UNTIL = sys.argv[3]
PLATFORM_NAME = os.environ.get('PLATFORM_NAME')

scraper = sntwitter.TwitterSearchScraper(f"(from:{Username}) until:{UNTIL} since:{SINCE}")
tweets = []
for i, tweet in enumerate(scraper.get_items()):
    print(tweet)
    # data=[tweet.id,tweet.content,tweet.user.username,tweet.likeCount,tweet.retweetCount,tweet.replyCount]
    data = {
        "id_post": tweet.id,
        "Date": tweet.date.strftime("%Y-%m-%d"),
        "Heure": tweet.date.strftime("%H:%M:%S"),
        "content": tweet.content,
        "username": tweet.user.username,
        "likecount": tweet.likeCount,
        "retweetcount": tweet.retweetCount,
        "replycount": tweet.replyCount,
        "platformname": PLATFORM_NAME

    }
    tweets.append(data)
    if i > 800:
        break

tweet_df = pd.DataFrame(tweets, columns=["id_post","Date","Heure", "content", "username", "likecount", "reteweetcount", "replycount","platformname"])
tweet_df.to_csv('C:/Users/HP Probook/OneDrive/Images/Documents/PyCharm Community Edition 2021.1.3/jbr/bin/tweeter.csv', sep=";", encoding='utf-8', index=False)

tweet_json = tweet_df.to_json(orient='records', indent=4)
print(tweet_json.encode('utf-8').decode('utf-8'))

How to reproduce

"retweetcount": tweet.retweetCount,

Expected behaviour

it sould return number of tweets

Screenshots and recordings

No response

Operating system

Windows 11

Python version: output of python3 --version

3.9.13

snscrape version: output of snscrape --version

0.6.2.20230320

Scraper

TwitterSearchScrapper

How are you using snscrape?

Module (import snscrape.modules.something in Python code)

Backtrace

No response

Log output

No response

Dump of locals

No response

Additional context

No response

JustAnotherArchivist commented 1 year ago

snscrape version: output of snscrape --version

0.6.2.20230320

This is clearly incorrect. The search doesn't work at all with that version.

My test with the current dev version returns the retweetCount just fine.

ihabpalamino commented 1 year ago

acually twittersearch worked fine after your implementation i have only a probleme with retweetcount that returns null but other column of csv ar not empty it works fine

ihabpalamino commented 1 year ago

my bad the version i am using actually is 0.6.2.20230321.dev6+g1f46a1c

JustAnotherArchivist commented 1 year ago

Then try the current dev version instead. Most likely, b0fff238 fixed this two weeks ago.

ihabpalamino commented 1 year ago

now i am using snscrape-0.6.2.20230321.dev13+g786815d I still get the same problem

JustAnotherArchivist commented 1 year ago

Please share specific search queries that cause this for you. I tried with a number of users and since/until filters and was not able to reproduce it.

ihabpalamino commented 1 year ago

same code as i am using in username i replace it with elonmusk and the since until whatever i do as a date and the version of snscrape ia m using is 0.6.2.20230321.dev6+g1f46a1c

JustAnotherArchivist commented 1 year ago

So you didn't update to 0.6.2.20230321.dev13+g786815d?

ihabpalamino commented 1 year ago

So you didn't update to 0.6.2.20230321.dev13+g786815d?

i did today but still having same issue

JustAnotherArchivist commented 1 year ago

Please provide a complete debug log showing this issue.

ihabpalamino commented 1 year ago

its okey the problem was the mispelling of retweetcount in the dataframe

JustAnotherArchivist commented 1 year ago

🤦