[英]Using Jsoup to connect two URLs sequentially
i'm trying to get all images on this Category with resolution 1080 x 1920. 我正在尝试以1080 x 1920的分辨率获取此类别上的所有图像。
My Issue : 我的问题:
If i navigate to the site in first time ,site displays all images with all resolutions. 如果我是第一次导航到该站点,该站点将显示所有分辨率的所有图像。
BUT if i want it to display only images with resolution 1080 x 1920,i should access to this Filter 1080x1920 FIRST , after that Category displays all images with the resolution i need. 但是,如果我希望它仅显示分辨率为1080 x 1920的图像,则在该类别显示所有需要分辨率的图像之后,我应该访问此过滤器1080x1920 FIRST 。
What i have tried is access to Filter 1080x1920 first and get cookies to use it in Category : 我尝试过的是先访问过滤器1080x1920并获取Cookie以在Category中使用它:
@Override
protected List<Wallpaper> doInBackground(final Integer... integers) {
try {
firstPage = Jsoup.connect(getResources().getString(R.string.AllRequest))
.method(Connection.Method.POST)
.execute();
Map<String, String> Cookies = firstPage.cookies();
doc = Jsoup.connect(URL + "?page=" + integers[0])
.cookies(Cookies)
.get();
} catch (IOException e) {
e.printStackTrace();
}
if (doc != null) {
Elements newsHeadlines = doc.select("div.item-element");
for (Element headline : newsHeadlines) {
String thumb = headline.select("a").select("img").attr("src");
String title = headline.select("a").select("img").attr("title");
Wallpaper wallpaperInfo = new Wallpaper();
wallpaperInfo.setThumbnails(thumb);
wallpaperInfo.setTitle(title);
urls.add(wallpaperInfo);
}
}
return urls;
}
What i want is connect to Filter 1080x1920 first, after that Category . 我想要的是在该Category之后首先连接到Filter 1080x1920 。 Could you help me?
你可以帮帮我吗?
Thanks! 谢谢!
Solved my problem with add UserAgent
解决了添加
UserAgent
问题
try {
firstPage = Jsoup.connect(getResources().getString(R.string.AllRequest)).userAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36").method(Connection.Method.GET).execute();
Map<String, String> Cookies = firstPage.cookies();
doc = Jsoup.connect(URL + "?page=" + integers[0]).cookies(Cookies).get();
} catch (IOException e) {
e.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.