Jsoup返回的HTML与Web浏览器不同 [英] Jsoup returns html different from web browser
问题描述
我有一个url = "http://mp3.zing.vn/tim-kiem/playlist.html?q=Bảo Thy
Document doc = Jsoup.connect(url).get()
当我使用Jsoup
获取html时.它行不通.它返回与我使用浏览器时不同的html.我该如何解决这个问题.
when I use Jsoup
to get html. It doesn't work right. It returns the html which is different from when I use a browser. How can I solve this problem.
但是,当我使用不带参数的url(http://mp3.zing.vn)
时,它工作正常.
However, When I use url without parameters (http://mp3.zing.vn)
, It works right.
推荐答案
我已经解决了这个问题.
I have solve this problem.
http://mp3.zing.vn/tim-kiem/playlist.html?q=Bảo thy
参数是越南语单词,在这种情况下,此站点使用URL编码.因此,我必须将所有参数编码为UTF-8编码.
Parameter is vietnamese word and in this case, this site uses URL encoding. So that, I have to encode all of parameters to UTF-8 encoding.
keyword = URLEncoder.encode(keyword,"UTF-8");
和编码后的网址
http://mp3.zing.vn/tim-kiem/playlist.html?q=B%E1%BA%A3o%20thy
Jsoup工作正常.
Jsoup has worked right.
谢谢大家.关闭主题.
这篇关于Jsoup返回的HTML与Web浏览器不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!