Having trouble fetching the proper site in Java (second word for website search query gets cut off)

心已入冬 提交于 2019-12-13 04:54:47

问题


I am trying to search sears for an item, which I store in a String.

I notice that whenever I type:

http://www.sears.com/search=summer clothes

in the search bar in my google chrome, it automatically converts it to:

http://www.sears.com/search=summer%20clothes?catalogId=12605&storeId=10153&levels=Clothing&autoRedirect=true&viewItems=25&redirectType=CAT_REC_PRED

Therefore, my strategy is to have Jsoup fetch this site and follow redirects.

String url = "http://www.sears.com/search=summer clothes";
Document document = Jsoup.connect(url).followRedirects(true).get();

However, the website it actually takes me to is http://www.sears.com/search=summer?.... effectively chopping off "clothes".

Why might this be the case? I've tried replacing the spaces in the URLs with %20's though this actually results in an error.


回答1:


They could be using JavaScript redirect.



来源:https://stackoverflow.com/questions/19023292/having-trouble-fetching-the-proper-site-in-java-second-word-for-website-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!