bocchilorenzo / ntscraper

Scrape from Twitter using Nitter instances
MIT License
180 stars 29 forks source link

Scrape the name of the account a reply was directed to #49

Closed TomatoGreen2 closed 11 months ago

TomatoGreen2 commented 11 months ago

It seems something straightforward to implement as this element has its own banner. It would lead a lot of useful information for network analysis. Something like:

def _get_tweet_replies(self, tweet):
    """
    Extract reply header from a tweet

    :param tweet: tweet to extract header from
    :return: all headers
    """
    if tweet.find("div", class_="replying-to"):
        try:
            output = []
            for p in tweet.find("div", class_="replying-to").find_all("a"):
                output.append(p.text)                
        except:
            output = tweet.find("div", class_="replying-to").find("a").text
    else: output = ""
    return (output)

Also, a lot of thanks for that very useful tool!

bocchilorenzo commented 11 months ago

Hi, thanks for the issue. The scraper now extracts the usernames a tweet is replying to. If there are none, an empty list is returned.