【问题标题】:Getting error message "No javascript support found" instead of the response收到错误消息“未找到 JavaScript 支持”而不是响应
【发布时间】:2018-04-01 15:40:37
【问题描述】:

当我尝试在浏览器中向this website 发出请求时,我得到了我需要的 JSON 文本。我想在我的 Java 程序中发出相同的请求,但我收到一条错误消息。

这是我的java代码:

    public static void main(String[] args) throws IOException {
        String url = "http://www.biletix.com/solr/en/select/?start=0&rows=300&q=*:*&fq=start%3A%5B2018-04-01T00%3A00%3A00Z%20TO%202020-04-01T00%3A00%3A00Z%2B1DAY%5D&sort=score%20desc,start%20asc&&wt=json&indent=true&facet=true&facet.field=category&facet.field=venuecode&facet.field=region&facet.field=subcategory&facet.mincount=1&json.wrf=jQuery111304892331858278194_1522595307304&_=1522595307305";
        URLConnection connection = new URL(url).openConnection();
        InputStream inputStream = connection.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));

        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            sb.append(line);
        }
        bufferedReader.close();

        String returnedText = sb.toString();
        System.out.println(returnedText);
   }

当我运行这个程序时,我希望看到相同的结果,但我收到了这条消息:

<script>document.cookie = 'BXID=AAAAAAQESUmB+pCwyampPOjPp/TJoF5apqvu8IJ7uY9duhcYew==; path=/; domain=biletix.com';location.reload(true);</script><noscript>Javascript destegi bulunamadi. Lutfen javascript destegini aktiflestirin.</noscript>

在

【问题讨论】:

  • Java 程序不是浏览器。您必须接受该响应并将其正确地注入到 DOM 文档中,以便它做任何有意义的事情。

标签: javascript java json browser httprequest


【解决方案1】:

在发出请求时,只需添加一个值为 'BXID=AAAAAAWcAVhLxgA1Bsrrqa1wtjASbH/dlp2o5J/5Bcx3RsFUew==; 的标头 Cookie;路径=/;域=biletix.com'

你应该没事的

【讨论】:

  • 感谢它在我添加 connection.addRequestProperty("Cookie", "'cookie_value'"); 时起作用了;
猜你喜欢
  • 1970-01-01
  • 2016-08-21
  • 2018-04-21
  • 2019-12-18
  • 1970-01-01
  • 2016-06-06
  • 1970-01-01
  • 2015-09-28
  • 1970-01-01
相关资源
最近更新 更多