-
Notifications
You must be signed in to change notification settings - Fork 2
/
gre.py
44 lines (34 loc) · 1.06 KB
/
gre.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
from bs4 import BeautifulSoup
from random import randint
import urllib
import pynotify
import time
def sendMessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
webpage = urllib.urlopen('https://quizlet.com/58647605/kaplan-900-flash-cards').read()
# Parse the entire webpage
soup = BeautifulSoup(webpage)
word = []
meaning = []
# Scrape words from soup
for words in soup.find_all("span", class_="TermText qWord lang-en"):
# Convert ascii to string
word.append(words.text.encode("utf-8"))
# Scrape meanings from soup
for meanings in soup.find_all("span", class_="TermText qDef lang-en"):
meaning.append(meanings.text.encode("utf-8"))
print("Churning words !")
while(1):
index = randint(0,700)
print(index)
# First just pop the word on screen to wait for response
sendMessage(word[index],"")
# Adjust the response time between word and its meaning
time.sleep(15)
# Display the meaning with the word
sendMessage(word[index], meaning[index])
# Time after which a new word pops on screen
time.sleep(600)