Skip to content

When using eval for the link, if the result of the eval is a string use that directly #21

@BanchouBoo

Description

@BanchouBoo

Currently the way eval works for links is it will take the result and continue to treat it as an HTML object to try and pull the href value out of. In many cases, it makes more sense to construct a string for the URL directly instead of returning an HTML object.

For a real world example, I will be using https://twelvemen.neocities.org/2/blog as a reference. Every new post is just a new chunk of HTML on this page, with no anchor links to them. Nowadays, browsers have a feature that lets you link directly to a chunk of text on a page. Using the date text in each post entry, we can link directly to any post on this page, for example: https://twelvemen.neocities.org/2/blog#:~:text=7/14/25

Currently, the argument I'm passing to generate this link in RSS Guard is the following:

$BeautifulSoup("<a href=\"https://twelvemen.neocities.org/2/blog#:~:text=" + item.select_one("td p.grey").get_text() + "\"></a>

As you can see, I have to create a new HTML object using BeautifulSoup so that the script works properly. If it handled string results separately, it could be simplified to just:

$"https://twelvemen.neocities.org/2/blog#:~:text=" + item.select_one("td p.grey").get_text()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions