geminispace.info

gemini search engine
git clone https://git.clttr.info/geminispace.info.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

add_normalized_url.py (482B)


      1 from gus import constants
      2 from gus.lib.db_model import init_db, Page
      3 from gus.lib.gemini import GeminiResource, GeminiRobotFileParser
      4 
      5 def main():
      6     db = init_db(f"index.new/{constants.DB_FILENAME}")
      7     for page in Page.select():
      8         print(f"\nBefore: {page.normalized_url}")
      9         page.normalized_url = GeminiResource(page.url).normalized_url
     10         page.save()
     11         print(f"After : {page.normalized_url}")
     12     print("\nDone!")
     13 
     14 
     15 if __name__ == "__main__":
     16     main()