Commit 34cbb5ad448b8301d0e1e7ea62f9d6ef5d5aaa9d

Authored by Jonathan Wilson
1 parent b885b88b03
Exists in master and in 1 other branch dan

producer sends message to rabbit

Showing 1 changed file with 9 additions and 12 deletions   Show diff stats
... ... @@ -2,6 +2,8 @@ import pika
2 2 import configparser
3 3 import logging
4 4 import os
  5 +from lxml import html
  6 +import requests
5 7 from scraper import get_hacker_news_top_five
6 8 os.chdir(os.path.dirname(__file__))
7 9  
... ... @@ -28,7 +30,13 @@ connection = pika.BlockingConnection(pika.ConnectionParameters(
28 30 channel = connection.channel()
29 31 channel.queue_declare(queue='jons_news', durable=True)
30 32  
31   -message = "hello" #get_hacker_news_top_five()
  33 +# page = requests.get('https://news.ycombinator.com/')
  34 +# tree = html.fromstring(page.text)
  35 +# headlines = tree.xpath('//td[@class="title"]/a/text()')
  36 +message = 'string' #headlines[1]
  37 +# print (message)
  38 +# # print (get_hacker_news_top_five())
  39 +# print ("1")
32 40  
33 41 channel.basic_publish(exchange='',
34 42 routing_key='jons_news',
... ... @@ -37,14 +45,3 @@ channel.basic_publish(exchange='',
37 45 delivery_mode = 2, # Make message persistent
38 46 ))
39 47 logging.debug("Published: {0}".format(message))
40   -
41   -#Basic consumer code
42   -# def callback(channel, method, properties, body):
43   -# logging.debug("Received: {0}".format(body))
44   -# channel.basic_ack(delivery_tag = method.delivery_tag)
45   -
46   -# channel.basic_qos(prefetch_count=1)
47   -# channel.basic_consume(callback,
48   -# queue='jons_news')
49   -
50   -# channel.start_consuming()
51 48 \ No newline at end of file
... ...