-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathORus.py
54 lines (42 loc) · 1.32 KB
/
ORus.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
import datetime
import requests
import urllib
'''
x = datetime.datetime.now()
print(x.year)
print (x.strftime("%A"))
x = datetime.datetime(2019,1,1)
print(x)
print(x.year)
print(x.month)
print(x.day)
print(x.strftime("%A, %B %d %Y"))
'''
def form_cl_url(stream_name, year, month, day):
"""Return Oruslte chatlog for specified stream, and date
stream_name :: str
year :: int
month :: month
day :: day
"""
base_url = "https://overrustlelogs.net"
arg_date = datetime.datetime(year, month, day)
month_full = arg_date.strftime("%B")
year_full = arg_date.strftime("%Y")
date_full = arg_date.strftime("%Y-%m-%d")
url = "{}/{}%20chatlog/{}%20{}/{}.txt".format(base_url,
stream_name,
month_full,
year_full,
date_full)
return url
if __name__ == "__main__":
cl_url = form_cl_url('Sodapoppin', 2019, 5,30)
print(cl_url)
req = urllib.request.Request(cl_url, headers={'User-Agent' : "Magic Browser"})
con = urllib.request.urlopen( req)
data = con.read()
text = data.decode('utf-8')
words = text.split(' ')
for word in words:
print(word)