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 (将#修改为@)