当前位置:   article > 正文

java 判断链接是否有效_如何用java判断一个百度云链接是否有效?

验证百度网盘链接是否可用java

public static void main(String[] args) {

Document doc = null;

try {

doc = Jsoup.connect("https://pan.baidu.com/s/1gfinNhh").timeout(5 * 1000)

.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31")

.header("Cookie", "BAIDUID=3493205C1471EB5F1E27F366ED9713C2:FG=1; BIDUPSID=3493205C1471EB5F1E27F366ED9713C2; PSTM=1499826354; PANWEB=1; bdshare_firstime=1499839613146; FP_UID=d6297086ace66e85af18a244318efd02; BDUSS=hNNVdhTVd6UEpsWlNiajU4WmM2VlJZRkp-c2otMlh6UVRlaTdENUtUakdTWTFaTVFBQUFBJCQAAAAAAAAAAAEAAAB37nOtxM66zti8srvGxgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMa8ZVnGvGVZaH; STOKEN=94038b45d7946baa69c708f8eab3068a982c853c98c32433f7b3ae20da37391e; SCRC=dd7d90d2bff34203f0be0317a1eb41cf; BDCLND=t1wcAOzyLmyZdplefWeUzGtlU%2BZjvZoUqavyYmJmVak%3D; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; PSINO=7; H_PS_PSSID=1466_21109_17001_19898_20927; Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1499839682,1499841922,1499843792,1500458033; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1500458396; PANPSC=5676771253663392184%3AD6NVGkQPO1W%2BNPRGOXuNkun90oj%2BY%2FIsKLSvHXcyIk73RCn7hN7MbuhsXy%2FwDjyAhHVnG%2BbTsWfxTJ3v1z1m%2Bh4XiP1WnkH03pBa%2Fo0YJZj8cU%2F5SgrbTrDDqi%2BsdH8nSlgwQk9xY5zQtFsPtE77GxGUdLbIxdFT%2B%2Bo8ht7g5D2LIWeznIUCtSkA0KYPulwlfkiVl%2Ff%2FRfx4kU4b9dv9by76Oxw8WnAw")

.get();

System.out.println(doc);

} catch (IOException e) {

e.printStackTrace();

}

}

带上Cookie 就好了,

还有一个问题,cookie是会过期的,可以每次先访问百度官网,然后拿到返回的cookie再带上这个cookie去请求百度云的链接,这样应该就不会有cookie失效的问题了

推荐阅读:雁高飞:每个程序员都该学会的Maven知识​zhuanlan.zhihu.com55a74c899e6bff4413f059b52fd7011e.png雁高飞:阿里某员工面试华为后吐槽:面试官太水,反问几句都答不上来​zhuanlan.zhihu.com8419be60de9e6252bdd17517c6017224.png雁高飞:GitHub上的项目受美国出口管制吗?​zhuanlan.zhihu.com41b2e57524766d22fed895c17c8f9753.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/476186
推荐阅读
相关标签
  

闽ICP备14008679号