File tree Expand file tree Collapse file tree 2 files changed +34
-7
lines changed Expand file tree Collapse file tree 2 files changed +34
-7
lines changed Original file line number Diff line number Diff line change 1
- import http .cookiejar , urllib .request , urllib .parse
1
+ from http .cookiejar import CookieJar
2
+ import urllib .parse
2
3
import bz2
3
- import http . cookies
4
+ import requests
4
5
5
6
6
7
def main ():
7
- cookie_jar = http .cookiejar .CookieJar ()
8
+ first_step ()
9
+ # second_step()
10
+
11
+
12
+ def first_step ():
13
+ cookie_jar = CookieJar ()
8
14
opener = urllib .request .build_opener (urllib .request .HTTPCookieProcessor (cookie_jar ))
9
15
ary = []
10
16
next_number = open_url (cookie_jar , opener , "12345" , ary )
@@ -17,8 +23,7 @@ def main():
17
23
print ("ary length is {}" .format (len (ary )))
18
24
print ("bs is {}" , encoded_string )
19
25
password = bz2 .decompress (str .encode (encoded_string , "latin1" ))
20
- print ("pw is {}" .format (password ))
21
-
26
+ print ("{}" .format (password .decode ()))
22
27
23
28
24
29
def open_url (cookie_jar , opener , number , ary ):
@@ -52,5 +57,13 @@ def find_next_number(doc):
52
57
return number
53
58
54
59
60
+ def second_step ():
61
+ php_url = "http://www.pythonchallenge.com/pc/stuff/violin.php"
62
+ cookies = {"info" :"the flowers are on their way" }
63
+ res = requests .get (php_url , cookies = cookies )
64
+ response_doc = res .text
65
+ print (response_doc )
66
+
67
+
55
68
if __name__ == "__main__" :
56
69
main ()
Original file line number Diff line number Diff line change @@ -10,8 +10,22 @@ gunzip deltas.gz
10
10
11
11
#### 17
12
12
result: http://www.pythonchallenge.com/pc/return/balloons.html
13
-
14
- 1 .
13
+ ``` python
14
+ from http.cookiejar import CookieJar
15
+ import urllib.parse
16
+ import bz2
17
+ import requests
18
+ ```
19
+ - the small pic in left bottom director us to [ Level 3] ( http://www.pythonchallenge.com/pc/def/linkedlist.php )
20
+ - use CookieJar to catch cookies
21
+ - use bz2 to decompress
22
+
23
+ > is it the 26th already? call his father and inform him that "the flowers are on their way". he\' ll understand.
24
+ - 26th director us to [ Level 15] ( http://www.pythonchallenge.com/pc/return/uzi.html )
25
+ - mozart‘s farther is * Leopold Mozart*
26
+ - * call* director us to [ phonebook in Level 12] ( http://www.pythonchallenge.com/pc/phonebook.php )
27
+ - Level 12 * Bert* tell us to use the first name
28
+ - inform him let us remember that the cookies are {"info":"value"}
15
29
16
30
#### 16
17
31
result: http://www.pythonchallenge.com/pc/return/romance.html
You can’t perform that action at this time.
0 commit comments