Commit b885b88b03094b4ac0b725f8403cef95fd175d2d

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

producer connected to rabbit server, WIP web scraper

Showing 2 changed files with 15 additions and 1 deletions   Show diff stats
... ... @@ -0,0 +1,13 @@
  1 +from lxml import html
  2 +import requests
  3 +
  4 +def get_hacker_news_top_five():
  5 + page = requests.get('https://news.ycombinator.com/')
  6 + tree = html.fromstring(page.text)
  7 +
  8 + headlines = tree.xpath('//td[@class="title"]/a/text()')
  9 +
  10 + return headlines[1]
  11 +
  12 +if __name__ == "__main__":
  13 + print(get_hacker_news_top_five())
0 14 \ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@ import pika
2 2 import configparser
3 3 import logging
4 4 import os
  5 +from scraper import get_hacker_news_top_five
5 6 os.chdir(os.path.dirname(__file__))
6 7  
7 8 config = configparser.SafeConfigParser()
... ... @@ -27,7 +28,7 @@ connection = pika.BlockingConnection(pika.ConnectionParameters(
27 28 channel = connection.channel()
28 29 channel.queue_declare(queue='jons_news', durable=True)
29 30  
30   -message = "Hello world!"
  31 +message = "hello" #get_hacker_news_top_five()
31 32  
32 33 channel.basic_publish(exchange='',
33 34 routing_key='jons_news',
... ...