Jegg
Jegg

Reputation: 549

How to get web page source from a cookie drived web site using Java

It is easy to get web page source if it has a regular url with it.

Here is an answer for it: How to get a web page's source code from Java

But some websites, like Sobeys. they are asking you to input your location first then you can get different flyers with different locations. It seems like it is setting up cookies for your preference and then you can get same content of flyers until you close your browser.

My question is, for this kind of webpage, how can I get the web page source of specific flyers (for exmple I want to get the flayers from Sobeys at Danforth Toronto) using Java? I can't use https://www.sobeys.com/en/flyer as it appears to be the same all the time. But how do I get the specific web page source for my flyers?

Upvotes: 0

Views: 490

Answers (1)

Patrick Murphy
Patrick Murphy

Reputation: 2329

Try using java to visit https://www.sobeys.com/en/stores/sobeys-danforth/preferred as it sets the cookie you want, otherwise it returns this cookie

_carrot-core_session=bCt5WnJadHluUWdlbEVPYkVmb3JQbDc1a2dLWHFYUWw5NlVFVUtUblpRRHJLUEEyZ1MzamN2UjVIWGlSZzBEZDlDUTRxM2JkaEpZeUdNVHh2NUFvVjVxQWM4L015Zm1kaG5wVU5nUytocGRhdzhFMGZvc0pFM090ek41OTVVTy96d2ovTmNBOEdqUDk2dmllUjZoR1BDMEF3S2VCR21SM2thMmlidW01UmIyWmNaRm5sbEZkMjNhRElmakpLd3NvUGxPUTcvdDdlZTZ2UGFWN3BucXZUNkxwWW5ENjZ1TEc1WFpmTlBIT2JsODBkNlI4VHV0S3BuZy81b1JRdytoOS0tdGFpWUIydDNRb1BCeWJPN2psbGxkQT09--b4e4aab475a9d016944bcf0e1207c561e7568b78; domain=.sobeys.com; path=/; HttpOnly

Try looking here: How to set Cookies at Http Get method using Java

Sorry I can't Help any more.

Upvotes: 1

Related Questions