Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Java中获取正确站点时遇到问题(网站搜索查询的第二个单词被切断)_Java_Html_Search_Jsoup_Connect - Fatal编程技术网

在Java中获取正确站点时遇到问题(网站搜索查询的第二个单词被切断)

在Java中获取正确站点时遇到问题(网站搜索查询的第二个单词被切断),java,html,search,jsoup,connect,Java,Html,Search,Jsoup,Connect,我试图在西尔斯搜索我存储在字符串中的项目 我注意到每当我输入: http://www.sears.com/search=summer clothes 在我的谷歌浏览器的搜索栏中,它会自动将其转换为: http://www.sears.com/search=summer%20clothes?catalogId=12605&storeId=10153&levels=Clothing&autoRedirect=true&viewItems=25&redirec

我试图在西尔斯搜索我存储在字符串中的项目

我注意到每当我输入:

http://www.sears.com/search=summer clothes
在我的谷歌浏览器的搜索栏中,它会自动将其转换为:

http://www.sears.com/search=summer%20clothes?catalogId=12605&storeId=10153&levels=Clothing&autoRedirect=true&viewItems=25&redirectType=CAT_REC_PRED
因此,我的策略是让Jsoup获取这个站点并遵循重定向

String url = "http://www.sears.com/search=summer clothes";
Document document = Jsoup.connect(url).followRedirects(true).get();
然而,它实际带我去的网站是?。。。。有效地砍掉“衣服”


为什么会这样?我尝试过用%20替换URL中的空格,但这实际上会导致错误。

他们可能使用JavaScript重定向。

如果是这样,我该如何解决?您可以尝试Selenium或PhantomJS在emulator中运行此页面并获取结果,但这完全是另一回事。不幸的是,Jsoup对JS无能为力。