Giter Club home page Giter Club logo

Comments (4)

Lyfhael avatar Lyfhael commented on July 23, 2024 1

Hi, it's next in my to-do list

from deletetweets.

titodelas avatar titodelas commented on July 23, 2024

Adding an option to filter tweets by date in your existing JavaScript code can be a bit complex because Twitter's API does not provide direct filtering by date. However, you can modify your script to filter tweets by their creation date after fetching them. Here's how you can do that:

  1. Add a filterByDate function to filter tweets by date. This function will take the entries (tweet data) as input and return filtered entries based on the date range you specify.
function filterByDate(entries, startDate, endDate) {
  return entries.filter((tweet) => {
    const createdAt = new Date(tweet["legacy"]["created_at"]);
    return createdAt >= startDate && createdAt <= endDate;
  });
}
  1. Define your desired date range by creating startDate and endDate objects. For example, to filter tweets from January 1, 2023, to February 28, 2023:
const startDate = new Date("2023-01-01T00:00:00Z");
const endDate = new Date("2023-02-28T23:59:59Z");
  1. Modify your main loop to include date filtering. After fetching tweets using fetch_tweets, use the filterByDate function to filter the tweets based on the date range:
entries = await fetch_tweets(next);
entries = filterByDate(entries, startDate, endDate); // Apply date filtering
next = await log_tweets(entries);
await delete_tweets(tweets_to_delete);
tweets_to_delete = [];
await sleep(3000);

With these modifications, your script will fetch tweets and then filter them to include only those that fall within the specified date range. Make sure to adjust the startDate and endDate to match your desired date filtering criteria.

from deletetweets.

titodelas avatar titodelas commented on July 23, 2024

I don't know if it works, it's just theory. I hope it can help you ;)

from deletetweets.

Lyfhael avatar Lyfhael commented on July 23, 2024

I don't know if it works, it's just theory. I hope it can help you ;)

done, I added explanation how to do it in the readme :)

from deletetweets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.