I'm trying to make an RSS scraper to pull articles from RSS feeds and export them to text files, to be used either in my BBS bulletins or message areas
I found a web page that supposedly does exactly this, however using the code and testing I get the Folliwing error:
python scraping.py
File "scraping.py", line 5
def
hackernews_rss('https://news.ycombinator.com/rss'):
^
SyntaxError: invalid
syntax
The code is:
# scraping function
def hackernews_rss('https://news.ycombinator.com/rss'):
try:
r = requests.get()
return print('The scraping job succeeded: ', r.status_code)
except Exception as e:
print('The scraping job failed. See exception: ')
print(e)print('Starting scraping')
hackernews_rss()
print('Finished scraping')
Any idea what I flubbed?
python scraping.py
File "scraping.py", line 5
def
hackernews_rss('https://news.ycombinator.com/rss'):
^
SyntaxError: invalid
syntax
The code is:
# scraping function
def hackernews_rss('https://news.ycombinator.com/rss'):
There should be a variable there between the (), not a constant in this function definition.
try:
r = requests.get()
Is 'requests' defined of set somewhere? I don't see it.
python scraping.py
File "scraping.py", line 5
def
hackernews_rss('https://news.ycombinator.com/rss'):
^
SyntaxError: invalid
syntax
The code is:
# scraping function
def hackernews_rss('https://news.ycombinator.com/rss'):
There should be a variable there between the (), not a constant in
this function definition.
Ah, so my source is wrong.
| Sysop: | Eric Oulashin |
|---|---|
| Location: | Beaverton, Oregon, USA |
| Users: | 96 |
| Nodes: | 16 (0 / 16) |
| Uptime: | 06:05:13 |
| Calls: | 6,997 |
| Calls today: | 2 |
| Files: | 8,556 |
| U/L today: |
2 files (2,394K bytes) |
| D/L today: |
2,918 files (1,362M bytes) |
| Messages: | 369,030 |
| Posted today: | 2 |