Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. import java.io.IOException;
  2. import org.jsoup.Jsoup;
  3. import org.jsoup.nodes.Document;
  4. import static org.jsoup.Connection.*;
  5.  
  6. /**
  7. * Created by avi on 11/24/17.
  8. */
  9. public class ExpediaCurl {
  10.  
  11. public static void main(String[] args) {
  12. final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36";
  13.  
  14.  
  15. Response res = null;
  16. try {
  17. res = Jsoup.connect("http://www.expedia.co.jp/Osaka-Hotels-Hotel-Consort.h5522663.Hotel-Information?")
  18. .data("adults", "2", "children", "0", "chkin", "2017/12/13", "chkout", "2017/12/14")
  19. .method(Method.POST)
  20. .execute();
  21.  
  22. Document doc = res.parse();
  23. String sessionId = res.cookie("abucket");
  24. System.out.println(sessionId);
  25. Document doc2 = Jsoup.connect("https://www.expedia.co.jp/infosite-api/5522663/getOffers?clientid=KLOUD-HIWPROXY&token=bc9e0d07b9dcc14506a3ce5587703329a02e9f9e&brandId=0&countryId=0&isVip=false&chid=&partnerName=&partnerPrice=0&partnerCurrency=&partnerTimestamp=0&adults=2&children=0&chkin=2017%2F12%2F13&chkout=2017%2F12%2F14&swpToggleOn=false&daysInFuture=&stayLength=&ts=1513141494203&evalMODExp=true&tla=OSA")
  26. .cookie("abucket", sessionId)
  27. .userAgent(USER_AGENT)
  28. .get();
  29. System.out.printf(doc2.html());
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. }
  35.  
  36. org.jsoup.HttpStatusException: HTTP error fetching URL. Status=400, URL=https://www.expedia.co.jp/infosite-api/5522663/getOffers?clientid=KLOUD-HIWPROXY&token=bc9e0d07b9dcc14506a3ce5587703329a02e9f9e&brandId=0&countryId=0&isVip=false&chid=&partnerName=&partnerPrice=0&partnerCurrency=&partnerTimestamp=0&adults=2&children=0&chkin=2017%252F12%252F13&chkout=2017%252F12%252F14&swpToggleOn=false&daysInFuture=&stayLength=&ts=1513141494203&evalMODExp=true&tla=OSA
  37. at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:679)
  38. at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:628)
  39. at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:260)
  40. at org.jsoup.helper.HttpConnection.get(HttpConnection.java:249)
  41. at ExpediaCurl.main(ExpediaCurl.java:31)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement