Advertisement
ranveer5289

Web Scraping

Jan 2nd, 2012
1,212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. So, lets suppose you are trying to login into www.addic7ed.com. These are the
  2. headers that were captured by the Live Http Header addon
  3. -------------------------------------------------------------------------------------------------------------------
  4. [I am just mentioning the relevant ones]
  5. -------------------------------------------------------------------------------------------------------------------
  6. 1)POST /dologin.php HTTP/1.1
  7. 2)User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
  8. 3)Referer: http://www.addic7ed.com/login.php
  9. 4)Cookie: PHPSESSID=ff39a25af0d71e6535d946b454dd94
  10. 5)username=ranveer5289&password=mypasswordissecret&Submit=Log+in
  11.  
  12. So, if you take a look the 5th header is the important one.
  13. Therefore first try to send this header using
  14.  
  15. Document doc = Jsoup.connect("http://www.addic7ed.com/login.php").data("username", "ranveer5289",
  16. "password", "mypasswordissecret","Submit","Log+in").post();
  17.  
  18. If than also you are not able to login than your site need cookies in the request
  19. to be send by your Java code.
  20.  
  21. Document doc = Jsoup.connect("http://www.addic7ed.com/login.php").data("username", "ranveer5289",
  22. "password","mypasswordissecret","Submit","Log+in").cookie("PHPSESSID","ff39a25af0d71e6535d946b454dd94").post();
  23.  
  24. for some website you may also need to set Referer and User-Agent.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement