Renamed feed retreival and parsing tool.
Browse files- functions/{helper_functions.py → feed_extraction.py} +0 -0
- functions/tools.py +11 -8
- rss_server.py +1 -1
functions/{helper_functions.py → feed_extraction.py}
RENAMED
File without changes
|
functions/tools.py
CHANGED
@@ -2,30 +2,33 @@
|
|
2 |
|
3 |
import json
|
4 |
import logging
|
5 |
-
import functions.
|
6 |
|
7 |
|
8 |
-
def
|
9 |
-
'''Gets RSS feed content from a given website.
|
|
|
|
|
|
|
10 |
|
11 |
Args:
|
12 |
-
|
13 |
|
14 |
Returns:
|
15 |
-
|
16 |
-
requested website
|
17 |
'''
|
18 |
|
19 |
logger = logging.getLogger(__name__ + '.get_content')
|
20 |
logger.info('Getting feed content for: %s', website)
|
21 |
|
22 |
-
feed_uri =
|
23 |
logger.info('find_feed_uri() returned %s', feed_uri)
|
24 |
|
25 |
if 'No feed found' in feed_uri:
|
26 |
return 'No feed found'
|
27 |
|
28 |
-
content =
|
29 |
logger.info('parse_feed() returned %s entries', len(list(content.keys())))
|
30 |
|
31 |
return json.dumps(content)
|
|
|
2 |
|
3 |
import json
|
4 |
import logging
|
5 |
+
import functions.feed_extraction as extraction_funcs
|
6 |
|
7 |
|
8 |
+
def get_feed(website: str) -> list:
|
9 |
+
'''Gets RSS feed content from a given website. Can take a website or RSS
|
10 |
+
feed URL directly, or the name of a website. Will attempt to find RSS
|
11 |
+
feed and return title, summary and link to full article for most recent
|
12 |
+
items in feed
|
13 |
|
14 |
Args:
|
15 |
+
website: URL or name of website to extract RSS feed content from
|
16 |
|
17 |
Returns:
|
18 |
+
JSON string containing the feed content or 'No feed found' if a RSS
|
19 |
+
feed for the requested website could not be found
|
20 |
'''
|
21 |
|
22 |
logger = logging.getLogger(__name__ + '.get_content')
|
23 |
logger.info('Getting feed content for: %s', website)
|
24 |
|
25 |
+
feed_uri = extraction_funcs.find_feed_uri(website)
|
26 |
logger.info('find_feed_uri() returned %s', feed_uri)
|
27 |
|
28 |
if 'No feed found' in feed_uri:
|
29 |
return 'No feed found'
|
30 |
|
31 |
+
content = extraction_funcs.parse_feed(feed_uri)
|
32 |
logger.info('parse_feed() returned %s entries', len(list(content.keys())))
|
33 |
|
34 |
return json.dumps(content)
|
rss_server.py
CHANGED
@@ -39,7 +39,7 @@ with gr.Blocks() as demo:
|
|
39 |
submit_button = gr.Button('Submit')
|
40 |
|
41 |
submit_button.click( # pylint: disable=no-member
|
42 |
-
fn=tool_funcs.
|
43 |
inputs=website_url,
|
44 |
outputs=output,
|
45 |
api_name='Get RSS feed content'
|
|
|
39 |
submit_button = gr.Button('Submit')
|
40 |
|
41 |
submit_button.click( # pylint: disable=no-member
|
42 |
+
fn=tool_funcs.get_feed,
|
43 |
inputs=website_url,
|
44 |
outputs=output,
|
45 |
api_name='Get RSS feed content'
|