• 欢迎来到老丁学习笔记

百度链接如何解码

python与seo laoding 2年前 (2017-09-26) 903次浏览 0个评论

从日志“访问来源”中获取来自百度方面的链接,这些链接完全看不懂,并且有重定向和编码,如下图所示:

https://www.baidu.com/baidu.php?sc.p13K00afhoYcwjS7PwEuRDTtBBQzVa51heijQ1uzSauZJMav29kdM4EkLSli5mrgtm_TETFo56t2GOxB7m_vowAoasyRftNF7BerwzvcwcXBFYJj4uKlZlyWKubxCsH_tgLD4VcVhZ7UX7k16sqogdNyBpYyTQS3JRlr_y6spcHdugTEA6.DR_jI_kE9wKLCmhnheI8lLt_T2mbtEjfmoyFWxElXrHkLI5QRze-kl-9h9mzN4r1BC0.U1Yk0ZDqdlWgC_5BVqZFlQ1AzqBzknOadPBdknL3dU30IjLj3oxwzqBzk0KGUHYznWR0u1dsTLwz0ZNG5yF9pywdUAY0TA-b5Hcd0APGujYznjc0UgfqnH0kPdtknjD4g1nvnjD0pvbqn0KzIjY4P1T0uy-b5fKBpHYznjwxnHRd0AdW5HmYPW03rHfLPNtvPjmsrjTknH9xn0KkTA-b5H00TyPGujYs0ZFMIA7M5H00ULu_5HDsnWDzQywlg1DsrHT1QH7xnH04rHmVuZGxnHDsnjDVnNtknH0kPaYzg1Dknjf1Qywlg1DknjT1QH-xnHDznWTVuZGxnHDYnWcVnNtknHRknBdbX-tknHmLridbX-tknWDVuZGxnHczrjDVuZGxnHczrjfVnNtknWc3PzdbX-tknWm3PBdbX-tknWTdradbX-tknW6LPadbX-tknWbzPadbX-tkn1DsnzdbX-tkn1DznzdbX-tkn1DYPidbX-tkn1ndnadbX-tkn1nLraYkg1D1PjfLQywlg1D1PWcLQywlg1D1PWnYQH7xnHnvrjDVuZGxnHnvrjnVnNtkn16knadbX-tkn16vradbX-tkPj0sPzYkg1DYnjnvQHPxnHfknjnVn-tkPjDkPBdbX-tkPjDkradbX-tkPjcsridbX-tznjInQHDsPdtzPWm4Qywlg1cvPW-mQywl0A7B5HKxn0K-ThTqn0KsTjYs0A4vTjYsQW0snj0snj0s0AdYTjYs0AwbUL0qnfKzpWYs0Aw-IWdsmsKhIjYs0ZKC5H00ULnqn0KBI1Ykn0K8IjYs0ZPl5fKYIgnqP1f4rHckP1D3rHRvrjnznjfYPfKzug7Y5HDdnjcknH0vnWDdrHf0Tv-b5ycLmWb4nyc4nj0sn1DdmW60mLPV5HwDrjmvnDD1wWcsPjTdn1R0mynqnfKsUWYs0Z7VIjYs0Z7VT1Ys0ZGY5HD0UyPxuMFEUHYsg1Kxn0Kbmy4dmhNxTAk9Uh-bT1Ysg1Kxn0Ksmgwxuhk9u1Ys0AwYpyfqn0K-IA-b5iYk0A71TAPW5H00IgKGUhPW5H00Tydh5HDv0AuWIgfqn0KhXh6qn0Khmgfqn0KlTAkdT1Ys0A7buhk9u1Yk0Akhm1Ys0APzm1Ydn1mznf&ck=1075.2.126.273.180.291.179.660&shh=www.baidu.com&sht=99632756_hao_pg&us=1.0.1.0.0.0.0&ie=utf-8&f=8&tn=99632756_hao_pg&wd=%E4%B8%93%E6%B3%A8%E5%85%8D%E8%B4%B9%E8%AE%BE%E8%AE%A1%E7%B4%A0%E6%9D%90%E4%B8%8B%E8%BD%BD%E7%9A%84%E7%BD%91%E7%AB%99&oq=%E4%B8%93%E6%B3%A8%E5%85%8D%E8%B4%B9%E8%AE%BE%E8%AE%A1%E7%B4%A0%E6%9D%90%E4%B8%8B%E8%BD%BD%E7%9A%84%E7%BD%91%E7%AB%99&rqlang=cn&bc=110101

对于单个链接,可以直接复制粘贴在浏览器网址栏中,搜索一下,就会显示出来原始的链接;不过一旦数量大了,一一复制搜索显然不现实了。这时候就需要使用到requests库,有两种方法:

方法一:直接get方法即可。如下所示:

结果如下图所示:

百度链接如何解码

缺点:链接多的时候,会对目标网站造成一点的访问压力。

方法二:利用header中的location字段获取,如下图所示:

百度链接如何解码


老丁笔记,如未注明 , 均为原创,欢迎转载丨转载请注明百度链接如何解码
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址