Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Update bookmark links if status code is 301 - Moved Permanently #903

Open
dominic248 opened this issue Nov 2, 2024 · 0 comments

Comments

@dominic248
Copy link

Hi Sascha,

Some website pages getting redirected to new link due to change in username or title
and in the Network tab it shows 301 status for the old link request.
It would be great to update bookmarked links to avoid duplicate bookmarks because of 301 status and redirects.

Note: pages which require login will get redirected too login page.
So need a checkbox to set the bookmark as autoupdate link if status is 301.

I've tested the below code for checking 301 status and getting the redirect link

import requests
url = "https://docs.new"  # Replace with your target URL
response = requests.get(url, allow_redirects=False)  # Prevent auto-following redirects
if response.status_code == 301:
    new_url = response.headers.get('Location')
    print("301 Redirected to:", new_url) 
    # output: 301 Redirected to: https://docs.google.com/document/u/0/create?usp=dot_new
else:
    print("Status Code:", response.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant