微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python Get Request 返回 415 错误 - 有谁知道如何解决这个问题?

如何解决Python Get Request 返回 415 错误 - 有谁知道如何解决这个问题?

使用以下代码,我收到 415 错误

        public static void main(String... args) throws IOException {
            List<String> data = new ArrayList<>();

            try {
                File f = new File("input6.txt");
                Scanner sc = new Scanner(f);

                while (sc.hasNext()) {
                    data.add(sc.nextLine());
                }
            } catch(FileNotFoundException e) {
                e.printstacktrace();
            }

            List<List<String>> group = new ArrayList<>();
            List<String> temp = new ArrayList<>();

            for (String line : data) {
                temp.add(line);
                if (line.trim().isEmpty()) {

                    group.add(new ArrayList<>(temp));
                    temp.clear();
                }
            }
        }

错误

读了一些书,人们说我需要 import requests headers = { #"Content-Type": "text/html; charset=utf-8" #Tried this I get the same error "Cookie": "MYCOOKIE....","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Encoding": "gzip,deflate,br","Host": "hedgefunddb.com","User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML,like Gecko) Version/14.0.2 Safari/605.1.15","Accept-Language": "en-us","Referer": "https://hedgefunddb.com/Home/Funds","Connection": "keep-alive" } url = "https://hedgefunddb.com/Home/SearchFunds/2" page = requests.get(url,headers=headers) print(page) ,我试过并得到了相同的结果。尽管在其他地方人们说 Content-Type 请求不需要 Content-Type

感谢任何反馈 - 提前致谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。