-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
131 lines (116 loc) · 3.02 KB
/
run.py
File metadata and controls
131 lines (116 loc) · 3.02 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from bs4 import BeautifulSoup
import requests
import lxml
import json
from datetime import datetime
import time
import random
import sys
def alert():
url = sys.argv[1]
requests.get( url )
def check():
headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
'referer':'https://www.google.com/',
# "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
}
response = requests.get(
'https://www.lulus.com/products/captain-s-blog-tan-double-breasted-coat/579232.html',
headers=headers).text
soup = BeautifulSoup(response, 'lxml')
data = []
res = soup.findAll(text='S')
if not res:
print("wrong response")
print(soup)
# alert()
for container in res:
cur_size = container.find_parent('div')
if 'out-of-stock' in str(cur_size):
now = datetime.now()
current_time = now.strftime("%-I:%M %p")
print(current_time + ': Out of Stock')
else:
msg = BeautifulSoup(str(cur_size.find_parent()), features="lxml").prettify()
print(msg)
alert()
def spinning_cursor():
frames = [
"⢀⠀",
"⡀⠀",
"⠄⠀",
"⢂⠀",
"⡂⠀",
"⠅⠀",
"⢃⠀",
"⡃⠀",
"⠍⠀",
"⢋⠀",
"⡋⠀",
"⠍⠁",
"⢋⠁",
"⡋⠁",
"⠍⠉",
"⠋⠉",
"⠋⠉",
"⠉⠙",
"⠉⠙",
"⠉⠩",
"⠈⢙",
"⠈⡙",
"⢈⠩",
"⡀⢙",
"⠄⡙",
"⢂⠩",
"⡂⢘",
"⠅⡘",
"⢃⠨",
"⡃⢐",
"⠍⡐",
"⢋⠠",
"⡋⢀",
"⠍⡁",
"⢋⠁",
"⡋⠁",
"⠍⠉",
"⠋⠉",
"⠋⠉",
"⠉⠙",
"⠉⠙",
"⠉⠩",
"⠈⢙",
"⠈⡙",
"⠈⠩",
"⠀⢙",
"⠀⡙",
"⠀⠩",
"⠀⢘",
"⠀⡘",
"⠀⠨",
"⠀⢐",
"⠀⡐",
"⠀⠠",
"⠀⢀",
"⠀⡀"
]
while True:
for cursor in frames:
yield cursor
def spin( how_long ):
# how_long in 1 seconds
how_long *= 10
spinner = spinning_cursor()
for _ in range( how_long ):
tar = next(spinner)
msg = tar
sys.stdout.write( msg )
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\b' * (len(msg)))
starttime = time.time()
while True:
check()
minute = 5
spin(minute * 60 + random.randrange(60)) # unit is second