Performing a search using JSoup

Since JavaClub Soundcloud is discontinued, I want to search my site using JSoup. I am currently using this code:

Document doc = Jsoup
            .connect("https://soundcloud.com/search?q=deep%20house")
            .userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
            .timeout(5000).get();

      

But the web page gives me a message that I should be using a newer browser:

<p class="messageText sc-text-light">Your current browser isn't compatible with SoundCloud.<br>Please download one of our supported browsers. <a href="http://help.soundcloud.com/customer/portal/articles/552882-the-site-won-t-load-for-me-all-i-see-is-the-soundcloud-logo-what-can-i-do-">Need help?</a></p>

      

I tried using other user agents I found here , but nothing seems to work so far. What can I do to prevent this message from appearing?

0


source to share


1 answer


You can try the below snippet. User agent string taken from this stream.



Document doc = Jsoup
                .connect("https://soundcloud.com/search?q=deep%20house")
                .userAgent("Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19")
                .timeout(5000).get();
System.out.println(doc);

      

0


source







All Articles