• Error message

    From Charles Pierson@1:106/127 to All on Fri Feb 5 14:35:27 2021
    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?

    Thanks

    --- Mystic BBS v1.12 A46 2020/08/26 (Raspberry Pi/32)
    * Origin: theoasisbbs.ddns.net:1357 (1:106/127)
  • From Wilfred van Velzen@2:280/464 to Charles Pierson on Fri Feb 5 23:02:01 2021
    Hi Charles,

    On 2021-02-05 14:35:27, you wrote to All:

    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'):

    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.

    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()

    Here where you call it you can give the constant to the function, like:

    hackernews_rss('https://news.ycombinator.com/rss')

    print('Finished scraping')


    Any idea what I flubbed?


    Bye, Wilfred.

    --- FMail-lnx64 2.1.0.18-B20170815
    * Origin: FMail development HQ (2:280/464)
  • From Charles Pierson@2:250/1 to Wilfred van Velzen on Fri Feb 5 21:57:12 2021
    On 05 Feb 2021, Wilfred van Velzen said the following...
    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.

    try:
    r = requests.get()

    Is 'requests' defined of set somewhere? I don't see it.

    I'm going through the steps as they were laid out. I was hoping that going through the steps of sonething that says it works would help me pick it up better.Apparently this was a poor choice.

    --- Mystic BBS v1.12 A46 2020/08/26 (Raspberry Pi/32)
    * Origin: theoasisbbs.ddns.net:1357
  • From Wilfred van Velzen@2:280/464 to Charles Pierson on Sat Feb 6 12:13:48 2021
    Hi Charles,

    On 2021-02-05 21:57:12, you wrote to me:

    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.

    I don't know your source, so I can't comment on that. ;-)


    Bye, Wilfred.

    --- FMail-lnx64 2.1.0.18-B20170815
    * Origin: FMail development HQ (2:280/464)