Android jsoup,如何选择项目并转到下一页 [英] Android jsoup, how to select item and go to next page

查看:63
本文介绍了Android jsoup,如何选择项目并转到下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看香港国际金融中心商场商店的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆