Android jsoup,如何选择项目并转到下一页 [英] Android jsoup, how to select item and go to next page
问题描述
我想查看香港国际金融中心商场商店的iPhone4s库存状态.
I want to check Hong Kong IFC mall store's iPhone4s stock state.
So, I need to go Choose products to detect the stock state "choose product link". But before I go to the Choose product pages, it necessary to choose store in previous page. if I didn't choose the store, and direct go to choose product page, it will display "Your session timed out."
如何在苹果商店储备,然后通过jsoup转到下一页?
How do I programmatically choose IFC mall in Apple store reserve and go to next pages by jsoup?
推荐答案
它将显示您的会话超时."
会话由cookie支持.您需要通过在后续请求上发送回检索到的响应cookie来维护会话.
The session is backed by cookies. You need to maintain the session by sending the retrieved response cookies back on subsequent requests.
// #1.
Connection connection1 = Jsoup.connect("http://example.com/firstpage");
Response response1 = connection1.execute();
Map<String, String> cookies = response1.cookies();
Document document1 = response1.parse(); // If necessary.
// ...
// #2.
Connection connection2 = Jsoup.connect("http://example.com/nextpage").cookies(cookies).data("param1", "value1");
Response response2 = connection2.execute();
cookies.putAll(response2.cookies());
Document document2 = response2.parse();
// ...
// Repeat #2.
这篇关于Android jsoup,如何选择项目并转到下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!