收到错误消息“找不到javascript支持”而不是响应

时间:2018-04-01 15:40:37

标签: javascript java json browser httprequest

当我尝试在浏览器中向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>

在&lt; noscript&gt;中标记它基本上说:“没有找到Javascript支持。请启用javascript支持。”

我如何使这项工作得到与浏览器相同的结果?

1 个答案:

答案 0 :(得分:0)

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

你应该没事