Skip to content

Instantly share code, notes, and snippets.

@smilerightnow
Created October 5, 2022 14:25
Show Gist options
  • Select an option

  • Save smilerightnow/9b736101829bbae98da3abb1dfff0330 to your computer and use it in GitHub Desktop.

Select an option

Save smilerightnow/9b736101829bbae98da3abb1dfff0330 to your computer and use it in GitHub Desktop.
import feedparser, requests, time, re
## pip install feedparser
sent = []
twitter_accounts = ["BBCWorld", "Peanuts50YrsAgo"] ## add twitter usernames here.
def send_msg(link, author):
data = {
"content": f"**{author}**: {link}",
"username": "Twitter",
"avatar_url": "https://abs.twimg.com/favicons/twitter.2.ico"}
r = requests.post(WEBHOOK_URL, json=data) ## replace WEBHOOK_URL with your webhook.
def scrapper(first):
for username in twitter_accounts:
d = feedparser.parse(f'https://nitter.net/{username}/rss')
if d["status"] == 200:
for entry in d['entries']:
link = entry["link"].replace("nitter.net", "twitter.com").replace("#m", "")
status_id = re.findall("status\/(\d*)", link)[0]
if not status_id in sent:
sent.append(status_id)
if not first:## dont send a lot of messages the first time.
send_msg(link, username)
time.sleep(2)## ratelimit of discord webhook. 1msg/2sec
first = True
while True:
scrapper(first)
time.sleep(60)
first = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment