Skip to content

Instantly share code, notes, and snippets.

@bahorn
Created February 8, 2019 18:12
Show Gist options
  • Save bahorn/bfefdf157ba72c45f8d1446c0ce8f412 to your computer and use it in GitHub Desktop.
Save bahorn/bfefdf157ba72c45f8d1446c0ce8f412 to your computer and use it in GitHub Desktop.
Ideabot importer
import requests
import time
url = 'https://us-central1-hackathonideas-6e61d.cloudfunctions.net/addIdea'
def addIdea(author, idea):
r = requests.post(url, data={'author': author, 'idea': idea})
return r.status_code
with open('ideas.txt') as ideas:
for line in ideas.read().split('\n'):
try:
idea = line.split('. ')[1::][0]
author = '@covhacksoc'
sent = False
sleep = 1
while not sent:
if addIdea(author, idea) != 200:
sleep = sleep * 2
else:
sent = True
time.sleep(sleep)
except:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment