-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.py
More file actions
35 lines (28 loc) · 1019 Bytes
/
4.py
File metadata and controls
35 lines (28 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
from bs4 import BeautifulSoup, Comment
import re
characters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']
big_characters = [c.upper() for c in characters]
characters += big_characters
reg = r'[a-z][A-Z][A-Z][A-Z]([a-z])[A-Z][A-Z][A-Z][a-z]'
url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='
if __name__ == '__main__':
num = '12345'
res = []
new_res = []
fl_to_divide = 0
for i in range(400):
r = requests.get(url + num)
print('iteration={0}, res={1}'.format(i+1, r.text))
s = r.text.split()
if fl_to_divide == 1:
num = str(int(r.text.split()[-1]) // 2)
else:
num = s[-1]
if s[1] == 'Yes.':
fl_to_divide = 1
num = str(int(r.text.split()[-1]) // 2)
if r.text.find('and the next nothing') != 0:
new_res.append((i, r.text))
print(new_res)