-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
148 lines (100 loc) · 2.76 KB
/
test2.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# import urllib.request
# fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
# counts = dict()
# for line in fhand:
# words = line.decode().split()
# for word in words:
# counts[word] = counts.get(word, 0) + 1
# print(counts)
# exit()
import nltk
##from urllib import urlopen
import urllib.request
from bs4 import BeautifulSoup
#url = "http://news.bbc.co.uk/2/hi/health/2284783.stm"
#url = "http://data.pr4e.org/romeo.txt"
url = "https://www.rd.com/culture/random-trivia-never-knew/"
html = urllib.request.urlopen(url).read()
soup = BeautifulSoup(html)
# url = "http://news.bbc.co.uk/2/hi/health/2284783.stm"
# html = urllib3.urlopen(url).read()
# soup = BeautifulSoup(html)
# kill all script and style elements
for script in soup(["script", "style"]):
script.extract() # rip it out
# get text
text = soup.get_text()
# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())
# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
# drop blank lines
text = '\n'.join(chunk for chunk in chunks if chunk)
print(text)
exit()
##random number generator
def random_func(x):
for i in range(1):
rand_no = random.randint(0,5)
##define progress bar
import time
import time
import random
import csv
import time
import colorama
from colorama import init
from colorama import Fore, Back, Style
init()
##load random questions
with open('random_questions.csv', 'r') as f:
reader = csv.reader(f)
random_questions = list(reader)
import re
list = random_questions
random_questions = re.sub('[\[\]]','',repr(list))
##random number generator
def random_func(x):
for i in range(1):
rand_no = random.randint(0,5)
random_no = random_func(i)
print(random_no)
exit()
#---------------------------------------
from colorama import init
import time
init()
from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
time.sleep(0.3)
print(Fore.BLUE + 'some blue text text')
exit()
#-------------------------------------
import time
import random
import os
random_name = (
"hello, my name is RAD, what's your name? "
,"Oops, I was on mute, who's there? "
,"*Ding-dong, knock knock, who's at the door? "
,"RAD is the name, chatting is the game, so who you might be? "
,"To whom do I owe the pleasure of this chat? "
,"Name please? ")
greeting_positive = (
"good"
,"cool"
,"awesome"
,"wicked!"
,"feeling good"
,"all right!")
rand = random.Random()
rand_no = round(rand.uniform(0,5))
#var_name = random_questions[rand_no]
var_name = random_name[rand_no]
var_prefix = greeting_positive[rand_no]
var1 = input(var_name)
for i in var1:
print(i, end='', flush=True)
time.sleep(0.1)
print('\n')
exit ()