I'm trying to retrieve an article price from a website. The problem is, that the prices differ if you choose online price or store price. After selecting a store the website creates a cookie called: CP_GEODATA with a specific value. I tried to send the cookie in different ways, but I keep getting the online price.
public class Parser {
public static void main(String[] args) throws Exception {
Map<String, String> cookies = new HashMap<String, String>();
cookies.put("CP_COUNTRY ", "%7B%22country%22%3A%22DE%22%7D ");
cookies.put("CP_GEODATA ", "%7B%22location%22%3A-1%2C%22firstlocation%22%3A11%2C%22name%22%3A%22Hamburg%22%7D");
String url = "https://www.cyberport.de/?token=7a2d9b195e32082fec015dca45ba3aa4&sSearchId=565eee12d987b&EVENT=itemsearch&view=liste&query=&filterkategorie=";
Connection.Response res = Jsoup.connect(url).cookies(cookies).data("query", "4B05-525").execute();
Document doc = res.parse();
String tester = doc.select("span[id=articlePrice] > span[class=basis fl]").text();
String tester2 = doc.select("span[id=articlePrice] > span[class=decimal fl]").text();
System.out.println(tester + tester2 + " €");
}
}
The value I'm getting back right now is 2,90 € but it should be 4,90 €. I already tried everything and searched the internet a lot but I did not find any solution working for me.
This is the article I'm receiving the price from: https://www.cyberport.de/micro-usb-2-0-kabel-usb-a-stecker-micro-b-stecker-0-5m--4B05-525_9374.html
I'm trying to receive the price for the store in Hamburg, Germany.
You can see the cookies I'm setting at the top.
Thank you for any help!