如何快速查找URL對應重導後的URL-使用Python

有時有些URL會因為分析, 或是廣告等原因, 需要進行重導(redirect), 然而在程式實作上, 若需要找到這個重導的結果URL, 要如何進行呢? 可以使用 requests library 的訪問連結後來取得, 程式如下:

response = requests.get('https://youtu.be/dQw4w9WgXcQ') 
print(response.url) # https://www.youtube.com/watch?v=dQw4w9WgXcQ&feature=youtu.be

利用 requests.get 的結果, 再將 response 的 url 取出即可.

參考資料:

https://stackoverflow.com/questions/36070821/how-to-get-redirect-url-using-python-requests

分類
好用軟體

Googlebot來源IP

最近因為要阻擋異常流量, 使用了 Cloudflare 的 WAF 功能, 對來訪問的所有流量進行管理驗證(Managed Challenge):

https://developers.cloudflare.com/waf/reference/cloudflare-challenges/#managed-challenge-recommended

使用了這個功能後, 對來第一次來訪問的訪客都會先出現一個 Cloudflare 驗證. 若沒有問題才可以正常訪問網站.

過沒幾天, Google Search Console發信來說明影響了 Googlebot 來爬內容, 有 403的回應.