-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskyeventmech.py
45 lines (35 loc) · 875 Bytes
/
skyeventmech.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
from spinner import Spinner
import form_filler as filler
import mechanize as mech
import requests
from PIL import Image
import urllib.request
def get_moon_dude():
f = open('assets/title.txt', 'r')
moon_dude = f.read()
f.close()
return moon_dude
def main_process(argv):
spinner = Spinner() #Make spinner
spinner.start()
print('argv:',argv)
br = mech.Browser()
br.set_handle_robots(False) # ignore robots
res = br.open('http://www.fourmilab.ch/cgi-bin/Yoursky')
link = br.find_link("Customise")
br.follow_link(link)
spinner.stop()
#Fill out form
filler.fill_form(br,argv)
#submit form
res = br.submit()
#download generate img
img=open('pic/sky.jpg','wb')
img.write(requests.get(br.geturl()).content)
img.close()
#Show cool moon dude
moon_dude = get_moon_dude()
print(moon_dude)
#display image
img = Image.open('pic/sky.jpg')
img.show()