Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.41 KB | None | 0 0
  1. import requests
  2. import json
  3.  
  4.  
  5. base = "http://www.XXXXXX.com/"
  6. url = "http://www.XXXXXX.com/login.php"
  7. scraped_url = "http://www.XXXXXX.com/cart.php?mode=wishlist"
  8. headers = {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36',
  9. "Connection":"keep-alive",
  10. "mode":"login",
  11. "Accept-Language":"en-US, en;q=0.8",
  12. "Accept-Encoding":"gzip, deflate, sdch",
  13. "store_language":"en",
  14. "RefererCookie":"deleted",#http%3A%2F%2Fwww.XXXXXX.com%2Fhome.php
  15. "Origin":"http://www.XXXXXX.com",
  16. "Upgrade-Insecure-Requests": "1",
  17. "P3P": "CP=NON CURa ADMa DEVa TAIa CONi OUR DELa BUS IND PHY ONL UNI PUR COM NAV DEM STA",
  18. "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8."
  19. }
  20.  
  21.  
  22. data = {"password":"Reallybadpassword",
  23. "username":"TheEmail@Gmail.com"}
  24.  
  25.  
  26. jar = requests.cookies.RequestsCookieJar()
  27.  
  28. req = requests.Request('GET', 'http://www.XXXXXX.com/login.php')
  29. r = req.prepare()
  30. s = requests.Session()
  31. s.send(r)
  32. s.headers.update
  33. s.jar.update
  34.  
  35. r = s.get(base, cookies=jar)
  36. s.headers.update
  37. jar.update
  38. print(r.history)
  39. print(r.status_code)
  40. print(r.url)
  41. print(r.json)
  42. print("################################################################################")
  43. print(r.headers)
  44. print("********************************************************************************")
  45. print(r.cookies)
  46. print("////////////////////////////////////////////////////////////////////////////////")
  47.  
  48.  
  49. r = s.post(url, params=data, cookies=jar, allow_redirects=True, headers=headers) #params=values,
  50. s.headers.update
  51. jar.update
  52.  
  53. print(r.history)
  54. print(r.status_code)
  55. print(r.url)
  56. print(r.json)
  57. print("################################################################################")
  58. print(r.headers)
  59. print("********************************************************************************")
  60. print(r.cookies)
  61. print("////////////////////////////////////////////////////////////////////////////////")
  62.  
  63.  
  64. r = s.get(scraped_url, params=data, cookies=jar)
  65. s.headers.update
  66. jar.update
  67.  
  68. print(r.history)
  69. print(r.status_code)
  70. print(r.url)
  71. print(r.json)
  72. print("################################################################################")
  73. print(r.headers)
  74. print("********************************************************************************")
  75. print(r.cookies)
  76. print("////////////////////////////////////////////////////////////////////////////////")
  77.  
  78.  
  79. s.close()
  80.  
  81. #####-RESPONSE FROM SITE TO CLI######
  82. Iam@Groot:/media/Iam/Drive/Backup/Documents/TestWebpages$ python3 login_scraper.py
  83. []
  84. 200
  85. http://www.XXXXXX.com/
  86. <bound method Response.json of <Response [200]>>
  87. ################################################################################
  88. CaseInsensitiveDict({'pragma': 'no-cache', 'server': 'nginx', 'last-modified': '
  89. Sun, 23 Apr 2017 20:33:45 GMT', 'content-type': 'text/html; charset=iso-8859-1',
  90. 'vary': 'Accept-Encoding', 'p3p': 'CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BU
  91. S IND PHY ONL UNI PUR COM NAV DEM STA"', 'set-cookie': 'xid_eb442=e8278c9dc379c
  92. 6dfae862b7bf2721138; path=/; domain=www.XXXXXX.com; httponly, RefererCookie=del
  93. eted; expires=Sat, 23-Apr-2016 20:33:44 GMT; path=/; domain=www.XXXXXX.com; htt
  94. ponly', 'date': 'Sun, 23 Apr 2017 20:33:45 GMT', 'transfer-encoding': 'chunked'
  95. , 'expires': 'Mon, 26 Jul 1997 05:00:00 GMT', 'connection': 'keep-alive', 'x-po
  96. wered-by': 'PleskLin', 'cache-control': 'no-store, no-cache, must-revalidate, p
  97. ost-check=0, pre-check=0', 'content-encoding': 'gzip'})
  98. ********************************************************************************
  99. <RequestsCookieJar[<Cookie xid_eb442=e8278c9dc379c6dfae862b7bf2721138 for .www.XXXXXX.com/>]>
  100. ////////////////////////////////////////////////////////////////////////////////
  101. []
  102. 200
  103. http://www.XXXXXX.com/login.php
  104. <bound method Response.json of <Response [200]>>
  105. ################################################################################
  106. CaseInsensitiveDict({'pragma': 'no-cache', 'server': 'nginx', 'last-modified': '
  107. Sun, 23 Apr 2017 20:33:45 GMT', 'content-type': 'text/html; charset=iso-8859-1',
  108. 'vary': 'Accept-Encoding', 'p3p': 'CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BU
  109. S IND PHY ONL UNI PUR COM NAV DEM STA"', 'set-cookie': 'xid_eb442=649b55131f4f7
  110. e9d6958560d3ed406c0; path=/; domain=www.XXXXXX.com; httponly, RefererCookie=del
  111. eted; expires=Sat, 23-Apr-2016 20:33:44 GMT; path=/; domain=www.XXXXXX.com; htt
  112. ponly', 'date': 'Sun, 23 Apr 2017 20:33:45 GMT', 'transfer-encoding': 'chunked'
  113. , 'expires': 'Mon, 26 Jul 1997 05:00:00 GMT', 'connection': 'keep-alive', 'x-po
  114. wered-by': 'PleskLin', 'cache-control': 'no-store, no-cache, must-revalidate, p
  115. ost-check=0, pre-check=0', 'content-encoding': 'gzip'})
  116. ********************************************************************************
  117. <RequestsCookieJar[<Cookie xid_eb442=649b55131695e9ff48560d3ed406c0 for .www.XXXXXX.com/>]>
  118. ////////////////////////////////////////////////////////////////////////////////
  119. (<Response [302]>,)
  120. 200
  121. http://www.XXXXXX.com/login.php
  122. <bound method Response.json of <Response [200]>>
  123. ################################################################################
  124. CaseInsensitiveDict({'pragma': 'no-cache', 'server': 'nginx', 'last-modified': '
  125. Sun, 23 Apr 2017 20:33:45 GMT', 'content-type': 'text/html; charset=iso-8859-1',
  126. 'vary': 'Accept-Encoding', 'p3p': 'CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BU
  127. S IND PHY ONL UNI PUR COM NAV DEM STA"', 'set-cookie': 'xid_eb442=649b55131f4f7
  128. e9d6958560d3ed406c0; path=/; domain=www.XXXXXX.com; httponly, RefererCookie=del
  129. eted; expires=Sat, 23-Apr-2016 20:33:45 GMT; path=/; domain=www.XXXXXX.com; htt
  130. ponly', 'date': 'Sun, 23 Apr 2017 20:33:46 GMT', 'transfer-encoding': 'chunked'
  131. , 'expires': 'Mon, 26 Jul 1997 05:00:00 GMT', 'connection': 'keep-alive', 'x-po
  132. wered-by': 'PleskLin', 'cache-control': 'no-store, no-cache, must-revalidate, p
  133. ost-check=0, pre-check=0', 'content-encoding': 'gzip'})
  134. ********************************************************************************
  135. <RequestsCookieJar[<Cookie xid_eb442=649b55131695e9ff48560d3ed406c0 for .www.XXXXXX.com/>]>
  136. ////////////////////////////////////////////////////////////////////////////////
  137. Iam@Groot:/media/Iam/Drive/Backup/Documents/TestWebpages$
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. #####-FROM CHROME LOGIN-######
  150.  
  151. Iam@Groot:~$ sudo ngrep -W byline -d any -q "XXXXXX"
  152. interface: any
  153. match: XXXXXX
  154.  
  155. T 192.168.1.5:56250 -> 22.156.106.185:80 [AP]
  156. POST /login.php HTTP/1.1.
  157. Host: www.XXXXXX.com.
  158. Connection: keep-alive.
  159. Content-Length: 133.
  160. Cache-Control: max-age=0.
  161. Origin: http://www.XXXXXX.com.
  162. Upgrade-Insecure-Requests: 1.
  163. User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36.
  164. Content-Type: application/x-www-form-urlencoded.
  165. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8.
  166. Referer: http://www.XXXXXX.com/home.php.
  167. Accept-Encoding: gzip, deflate.
  168. Accept-Language: en-US,en;q=0.8.
  169. Cookie: store_language=en; xid_eb442C_remember=TheEmail%40Gmail.com; RefererCookie=http%3A%2F%2Fwww.XXXXXX.com%2Fhome.php; GreetingCookie=Mr.+John+Doe; xid_eb442=649b55131695e9ff48560d3ed406c0.
  170. .
  171. xid_eb442=649b55131695e9ff48560d3ed406c0&is_remember=&mode=login&username=TheEmail%40Gmail.com&password=Reallybadpassword
  172.  
  173. T 22.156.106.185:80 -> 192.168.1.5:56250 [AP]
  174. HTTP/1.1 302 Found.
  175. Server: nginx.
  176. Date: Sun, 23 Apr 2017 20:03:04 GMT.
  177. Content-Type: text/html; charset=iso-8859-1.
  178. Transfer-Encoding: chunked.
  179. Connection: keep-alive.
  180. Expires: Mon, 26 Jul 1997 05:00:00 GMT.
  181. Last-Modified: Sun, 23 Apr 2017 20:03:03 GMT.
  182. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0.
  183. Pragma: no-cache.
  184. P3P: CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BUS IND PHY ONL UNI PUR COM NAV DEM STA".
  185. Set-Cookie: xid_eb442=7e00038d2gd56gtyh73cb97b1225afe; path=/; domain=www.XXXXXX.com; httponly.
  186. Set-Cookie: GreetingCookie=Mr.+John+Doe; expires=Fri, 20-Oct-2017 20:03:03 GMT; path=/; domain=www.XXXXXX.com; httponly.
  187. Location: http://www.XXXXXX.com/home.php.
  188. X-Powered-By: PleskLin.
  189. .
  190. d4.
  191. <br /><br />If the page is not updated in 2 seconds, please follow this link: <a href="http://www.XXXXXX.com/home.php">continue >></a><meta http-equiv="Refresh" content="0;URL=http://www.XXXXXX.com/home.php" />.
  192.  
  193.  
  194. T 192.168.1.5:56250 -> 22.156.106.185:80 [AP]
  195. GET /home.php HTTP/1.1.
  196. Host: www.XXXXXX.com.
  197. Connection: keep-alive.
  198. Cache-Control: max-age=0.
  199. Upgrade-Insecure-Requests: 1.
  200. User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36.
  201. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8.
  202. Referer: http://www.XXXXXX.com/home.php.
  203. Accept-Encoding: gzip, deflate, sdch.
  204. Accept-Language: en-US,en;q=0.8.
  205. Cookie: store_language=en; xid_eb442C_remember=TheEmail%40Gmail.com; RefererCookie=http%3A%2F%2Fwww.XXXXXX.com%2Fhome.php; xid_eb442=7e00038d2gd56gtyh73cb97b1225afe; GreetingCookie=Mr.+John+Doe.
  206. .
  207.  
  208.  
  209. T 22.156.106.185:80 -> 192.168.1.5:56250 [A]
  210. HTTP/1.1 200 OK.
  211. Server: nginx.
  212. Date: Sun, 23 Apr 2017 20:03:04 GMT.
  213. Content-Type: text/html; charset=iso-8859-1.
  214. Transfer-Encoding: chunked.
  215. Connection: keep-alive.
  216. Vary: Accept-Encoding.
  217. Expires: Mon, 26 Jul 1997 05:00:00 GMT.
  218. Last-Modified: Sun, 23 Apr 2017 20:03:04 GMT.
  219. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0.
  220. Pragma: no-cache.
  221. P3P: CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BUS IND PHY ONL UNI PUR COM NAV DEM STA".
  222. Set-Cookie: xid_eb442=7e00038d2gd56gtyh73cb97b1225afe; path=/; domain=www.XXXXXX.com; httponly.
  223. X-Powered-By: PleskLin.
  224. Content-Encoding: gzip.
  225.  
  226.  
  227. T 192.168.1.5:56250 -> 22.156.106.185:80 [AP]
  228. GET /home.php HTTP/1.1.
  229. Host: www.XXXXXX.com.
  230. Connection: keep-alive.
  231. Cache-Control: max-age=0.
  232. Upgrade-Insecure-Requests: 1.
  233. User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36.
  234. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8.
  235. Referer: http://www.XXXXXX.com/home.php.
  236. Accept-Encoding: gzip, deflate, sdch.
  237. Accept-Language: en-US,en;q=0.8.
  238. Cookie: store_language=en; xid_eb442C_remember=TheEmail%40Gmail.com; RefererCookie=http%3A%2F%2Fwww.XXXXXX.com%2Fhome.php; xid_eb442=7e00038d2gd56gtyh73cb97b1225afe; GreetingCookie=Mr.+John+Doe.
  239. .
  240.  
  241.  
  242. T 22.156.106.185:80 -> 192.168.1.5:56250 [A]
  243. HTTP/1.1 200 OK.
  244. Server: nginx.
  245. Date: Sun, 23 Apr 2017 20:03:04 GMT.
  246. Content-Type: text/html; charset=iso-8859-1.
  247. Transfer-Encoding: chunked.
  248. Connection: keep-alive.
  249. Vary: Accept-Encoding.
  250. Expires: Mon, 26 Jul 1997 05:00:00 GMT.
  251. Last-Modified: Sun, 23 Apr 2017 20:03:04 GMT.
  252. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0.
  253. Pragma: no-cache.
  254. P3P: CP="NON CURa ADMa DEVa TAIa CONi OUR DELa BUS IND PHY ONL UNI PUR COM NAV DEM STA".
  255. Set-Cookie: xid_eb442=7e00038d2gd56gtyh73cb97b1225afe; path=/; domain=www.XXXXXX.com; httponly.
  256. X-Powered-By: PleskLin.
  257. Content-Encoding: gzip.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement