Skip to content

Instantly share code, notes, and snippets.

@ripiuk
Last active March 29, 2018 11:25
Show Gist options
  • Save ripiuk/b792eb347ab3a9969e45c29513992e42 to your computer and use it in GitHub Desktop.
Save ripiuk/b792eb347ab3a9969e45c29513992e42 to your computer and use it in GitHub Desktop.
A simple nsq publisher using requests
import requests
import json
url = 'http://localhost:4151'
topic = 'is-hotel-active'
url = '{url}/pub?topic={topic}'.format(url=url, topic=topic)
rows = [{'hotel_id': '81', 'is_hotel_active': '0'},
{'hotel_id': '23', 'is_hotel_active': '1'},
{'hotel_id': '82', 'is_hotel_active': '1'}]
session = requests.Session()
for row in rows:
session.post(url=url, data=json.dumps(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment