gpt4 book ai didi

java - JSoup.connect 某些请求出现 403 错误

转载 作者:行者123 更新时间:2023-11-30 07:18:48 29 4
gpt4 key购买 nike

我尝试通过此页面的Jsoup.connect获取HTML源代码:https://bitskins.com/?market_hash_name=SSG+08+%7C+DARK+WATER+%28Field-Tested%29&is_stattrak=0&has_stickers=0&sort_by=bumped_at&order=desc

但是,我有错误:线程“main”org.jsoup.HttpStatusException 中出现异常:HTTP 获取 URL 时出错。 Status=403,URL=https://bitskins.com/?market_hash_name=SSG+08+%7C+DARK+WATER+%28Field-Tested%29&is_stattrak=0&has_stickers=0&sort_by=bumped_at&order=desc

我的代码是:

Document doc = Jsoup.connect("https://bitskins.com/?market_hash_name=SSG+08+%7C+DARK+WATER+%28Field-Tested%29&is_stattrak=0&has_stickers=0&sort_by=bumped_at&order=desc")
.data(":authority", "bitskins.com")
.data(":method", "GET")
.data(":path", "/?market_hash_name=SSG+08+%7C+DARK+WATER+%28Field-Tested%29&is_stattrak=0&has_stickers=0&sort_by=bumped_at&order=desc")
.data(":scheme", "https")
.data("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
.data("accept-encoding", "gzip, deflate, sdch, br")
.data("accept-language:", "ru,en-US;q=0.8,en;q=0.6")
.data("cache-control", "max-age=0")
.data("cookie", "__cfduid=d76231c8cccdbd5303a7d4feeb3f3a11f1466541718; _gat=1; _ga=GA1.2.1292204706.1466541721; request_method=POST; _session_id=5dc49c7814d5087ac51f9d9da20b2680")
.data("dnt", "1")
.data("upgrade-insecure-requests", "1")
.data("user-agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
.post();

问题是什么???

最佳答案

问题是,.data() 添加到表单数据,而不是标题。所以需要使用适当的方法来设置相关信息。请参阅以下内容来修复您的代码:

设置标题:

.header("键", "值")

设置表单数据:

.data("键", "值")

设置用户代理:

.userAgent("Mozilla...")

关于java - JSoup.connect 某些请求出现 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37954594/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com