project Utilities / File Location Listing avatar

utilities/file_location_listing#58: Meta keywords aren't correctly being extracted



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: v0.2.7
Created: 03-Jun-24 17:05



Description

I noticed that none of the pages on snippets.bentasker.co.uk have tags associated with them in results.

They definitely have meta keywords (although the inclusion of title is less than ideal):

<meta name="keywords" content="NGinx,Caching POST requests in NGinx,nginx,caching,HTTP,reverse proxy,cache,POST" />


Toggle State Changes

Activity


assigned to @btasker

The issue is quite subtle:

    # Check for keywords
    keywords = pagecontent.find('meta', attrs={'name':"keywords"})
    if keywords and len(keywords) > 0:
        tags = keywords['content'].split(",")

If I were to insert a print(keywords) we'd get the HTML element back.

However, it's not a string and the length of it is reported as 0, so we never enter the conditional. We should check the length of attribute content (and of course checking that exists)

verified

mentioned in commit 87c4b17618bdf79dde39c1d99b779e0691460999

Commit: 87c4b17618bdf79dde39c1d99b779e0691460999 
Author: B Tasker                            
                            
Date: 2024-06-03T18:08:48.000+01:00 

Message

fix: check for presence of meta keywords correctly (utilities/file_location_listing#58)

+2 -2 (4 lines changed)
verified

mentioned in commit fecdc7110b47c08d4eaad90d2cdce99e6806a842

Commit: fecdc7110b47c08d4eaad90d2cdce99e6806a842 
Author: B Tasker                            
                            
Date: 2024-06-03T18:12:37.000+01:00 

Message

fix: Skip a keyword if it appears to be the page title (noticed in utilities/file_location_listing#58)

+6 -1 (7 lines changed)