/
utils.py
72 lines (62 loc) · 1.59 KB
/
utils.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def getInputValue(text, inputName):
initialIndex = text.find(f'name="{inputName}"')
i = initialIndex
firstIndex = 0
while True:
if(text[i] == '<'):
firstIndex = i
break
i = i - 1
lastIndex = 0
i = initialIndex
while True:
if(text[i] == '>'):
lastIndex = i
break
i = i + 1
token_str = text[firstIndex:lastIndex]
tmpIndex1 = token_str.find('value="')
tmpLastIndex = 0
j = tmpIndex1 + len('value="')
while True:
if(token_str[j] == '"'):
tmpLastIndex = i
break
if(j >= len(token_str)):
break
j = j + 1
final_str = token_str[tmpIndex1+len(
'value="'):tmpLastIndex]
final_str = final_str[:-1]
return final_str
def getUrlValue(text, className):
initialIndex = text.find(f'class="{className}"')
i = initialIndex
firstIndex = 0
while True:
if(text[i] == '<'):
firstIndex = i
break
i = i - 1
lastIndex = 0
i = initialIndex
while True:
if(text[i] == '>'):
lastIndex = i
break
i = i + 1
token_str = text[firstIndex:lastIndex]
tmpIndex1 = token_str.find('href="')
tmpLastIndex = 0
j = tmpIndex1 + len('href="')
while True:
if(token_str[j] == '"'):
tmpLastIndex = i
break
if(j >= len(token_str)):
break
j = j + 1
final_str = token_str[tmpIndex1+len(
'href="'):tmpLastIndex]
final_str = final_str[:-1]
return final_str