Skip to content

Instantly share code, notes, and snippets.

@bindiry
Last active June 3, 2016 05:51
Show Gist options
  • Save bindiry/3fe32368562513256ef215092b264ee0 to your computer and use it in GitHub Desktop.
Save bindiry/3fe32368562513256ef215092b264ee0 to your computer and use it in GitHub Desktop.
Duolingo words
#!/usr/bin/env ruby
=begin
1. gem install selenium-webdriver
2. save urls after exec in console of google chrome
$('.skill-tree-row span a').each(function(i, obj){console.log('https://www.duolingo.com/' + $(obj).attr('href'));});
3. $ ruby duolingo.rb
=end
require 'selenium-webdriver'
class Duolingo
def initialize
@@driver = Selenium::WebDriver.for :chrome
@@driver.manage.timeouts.page_load = 30
@@wait = Selenium::WebDriver::Wait.new(timeout: 15)
@@xpath = "//div[@class='list-lesson-item past']/div/p"
end
def start
urls_file_path = 'duolingo_urls.txt'
words_file_path = 'duolingo_words.txt'
words_file = File.open(words_file_path, 'w')
File.open(urls_file_path, 'r') do |f|
i = 1
f.each_line do |line|
url = line.index("\n") > 0 ? line.sub!("\n", '') : line
puts "-------"
puts "#{i}: #{url}"
word_list = parse_url(url)
word_list.each do |words|
words.text.split(',').each do |word|
words_file.write("#{word.strip}\n")
puts word.strip
end
end
i += 1
end
end
words_file.close()
end
def parse_url(url)
@@driver.navigate.to url
count = 0
loop do
begin
@@wait.until { @@driver.find_element(xpath: @@xpath).displayed? }
rescue Selenium::WebDriver::Error::NoSuchElementError
puts 'wait for element...'
sleep 2
count += 1
end
break if @@driver.find_element(xpath: @@xpath) || count > 30
end
@@driver.find_elements(xpath: @@xpath)
end
end
Duolingo.new.start
https://www.duolingo.com/skill/en/Basics-1
https://www.duolingo.com/skill/en/Basics-2
https://www.duolingo.com/skill/en/Common-Phrases
https://www.duolingo.com/skill/en/Chinese-Holidays
https://www.duolingo.com/skill/en/Food
https://www.duolingo.com/skill/en/Animals
https://www.duolingo.com/skill/en/Plurals
https://www.duolingo.com/skill/en/Possessives
https://www.duolingo.com/skill/en/Pronouns-objective
https://www.duolingo.com/skill/en/Clothing
https://www.duolingo.com/skill/en/Verbs%3A-Present
https://www.duolingo.com/skill/en/Colors
https://www.duolingo.com/skill/en/Questions
https://www.duolingo.com/skill/en/Conjunctions
https://www.duolingo.com/skill/en/Prepositions
https://www.duolingo.com/skill/en/Dates-and-Time
https://www.duolingo.com/skill/en/Family
https://www.duolingo.com/skill/en/Occupations
https://www.duolingo.com/skill/en/Adjectives-1
https://www.duolingo.com/skill/en/Verbs%3A-Present-2
https://www.duolingo.com/skill/en/Adverbs
https://www.duolingo.com/skill/en/Places
https://www.duolingo.com/skill/en/Objects
https://www.duolingo.com/skill/en/People
https://www.duolingo.com/skill/en/Travel
https://www.duolingo.com/skill/en/Determiners
https://www.duolingo.com/skill/en/Numbers
https://www.duolingo.com/skill/en/Verbs%3A-Present-3
https://www.duolingo.com/skill/en/Education
https://www.duolingo.com/skill/en/Verbs%3A-Past-1
https://www.duolingo.com/skill/en/Verbs%3A-Infinitive
https://www.duolingo.com/skill/en/Verbs%3A-Past-2
https://www.duolingo.com/skill/en/Abstract-Objects-1
https://www.duolingo.com/skill/en/Adjectives-inflexion
https://www.duolingo.com/skill/en/Verbs%3A-Present-Perfect
https://www.duolingo.com/skill/en/Verbs%3A-Infinitive-2
https://www.duolingo.com/skill/en/Pronouns-relative
https://www.duolingo.com/skill/en/Verbs%3A-Past-Perfect
https://www.duolingo.com/skill/en/Abstract-Objects-2
https://www.duolingo.com/skill/en/Pronouns-reflexive
https://www.duolingo.com/skill/en/Nature
https://www.duolingo.com/skill/en/Verbs%3A-Gerund
https://www.duolingo.com/skill/en/Sports
https://www.duolingo.com/skill/en/Arts
https://www.duolingo.com/skill/en/Communication
https://www.duolingo.com/skill/en/Medical
https://www.duolingo.com/skill/en/Verbs%3A-Future
https://www.duolingo.com/skill/en/Politics
https://www.duolingo.com/skill/en/Verbs%3A-Phrasal-Future-Tense
https://www.duolingo.com/skill/en/Science
https://www.duolingo.com/skill/en/Verbs%3A-Future-Perfect
https://www.duolingo.com/skill/en/Business
https://www.duolingo.com/skill/en/Verbs%3A-Modal
https://www.duolingo.com/skill/en/Events
https://www.duolingo.com/skill/en/Verbs%3A-Conditional-Perfect
https://www.duolingo.com/skill/en/Attributes
man
woman
boy
I
girl
am
a
an
he
is
she
apple
and
eat
drink
drinks
water
eats
child
bread
boys
girls
we
read
newspaper
men
women
you
are
milk
sandwich
rice
they
the
reads
book
menu
it
children
have
has
hello
bye
thanks
yes
no
please
fine
morning
night
sorry
not
welcome
speak
speaks
english
goodbye
poetic
couplet
lunar
festival
fireworks
eve
firecrackers
mooncakes
dragon
sticky
dumplings
mid
prosper
celebrate
lantern
valentine
envelopes
parade
national
coffee
tea
beer
wine
juice
soup
oil
plate
cheese
pasta
orange
beef
fish
egg
fries
tomato
strawberry
lemon
food
hamburger
fruit
chicken
salt
meat
meal
pork
vegetarian
breakfast
lunch
dinner
sugar
cat
dog
horse
bird
elephant
duck
turtle
pet
crab
spider
animal
bear
mouse
monkey
rabbit
pig
fox
wolf
whale
swan
dove
snake
frog
dinosaur
hamster
sparrow
penguin
mosquito
fly
butterfly
tiger
owl
apples
books
newspapers
cats
dogs
horses
elephants
ducks
turtles
animals
birds
plates
sandwiches
ladies
heroes
mosquitoes
pianos
photos
flies
tomatoes
his
her
my
its
their
our
your
yours
ours
mine
them
us
him
me
wear
wears
shirt
shoes
skirt
coat
dress
pants
clothes
suit
hats
sock
uniform
scarf
ties
jacket
jeans
belt
bikini
boots
sandal
sweaters
slippers
write
writes
walks
walk
swims
swim
see
sees
cook
cooks
sleep
sleeps
run
runs
want
wants
like
likes
pay
pays
goes
go
play
plays
use
love
loves
rains
touch
hear
listen
hears
listens
say
says
tell
make
find
work
support
need
know
take
design
show
red
white
black
blue
yellow
green
gray
color
brown
colorful
pink
purple
light
dark
what
where
how
why
who
whose
which
when
question
answer
do
does
if
because
or
but
while
whenever
that
whether
from
in
on
at
of
between
by
for
about
without
with
to
as
after
out
under
off
during
among
behind
towards
near
over
except
against
today
tomorrow
tonight
afternoon
time
calendar
monday
tuesdays
wednesday
thursday
friday
day
saturday
sunday
year
age
week
month
hour
january
february
march
april
date
may
june
july
august
september
october
november
december
season
winter
spring
summer
fall
period
minute
century
party
stage
generation
birth
moment
evening
fair
decade
second
bit
until
midnight
daytime
autumn
mother
father
parents
son
daughter
brother
sister
siblings
husband
wife
uncle
aunt
family
marriages
dad
grandmother
grandfather
name
cousin
nephew
students
doctor
author
job
models
staff
director
career
police
artists
secretary
workers
lawyer
professional
judge
writer
officer
guard
actors
captain
soldiers
boss
profession
farmers
architect
engineer
waiter
waitress
little
tired
bilingual
same
next
general
real
local
special
open
own
personal
main
private
clean
dirty
different
left
human
recent
legal
important
available
future
possible
popular
living
official
final
whole
necessary
military
independent
responsible
excellent
perfect
beautiful
modern
positive
normal
minimum
traditional
wrong
cultural
interesting
religious
serious
sad
famous
negative
efficient
expensive
familiar
impossible
alive
convenient
opposite
afraid
frequent
wooden
careful
noisy
crowded
sign
think
change
return
call
save
look
live
come
study
offers
give
offer
needs
try
includes
ask
present
works
talk
mark
feel
makes
shows
remember
stop
wish
hope
searches
fail
include
pass
raise
believe
follow
returns
thank
comes
consider
takes
seems
rest
answers
starts
ends
trust
there
very
too
now
more
so
never
then
here
pretty
always
also
once
only
just
well
even
much
still
however
really
again
yet
away
already
least
ever
else
usually
far
currently
later
enough
soon
almost
late
especially
finally
sometimes
easily
generally
completely
approximately
exactly
clearly
anywhere
twice
possibly
normally
neither
nor
necessarily
definitely
slowly
perfectly
together
house
restaurant
beach
hotel
yard
bathroom
kitchen
airport
streets
city
church
castle
country
place
along
into
home
site
center
office
area
address
department
property
room
market
park
building
garden
region
island
front
district
bank
bar
provinces
inside
station
ground
valley
museum
coast
zone
corner
avenue
route
neighborhood
border
tower
cinema
prison
palace
towns
capital
community
port
right
square
top
west
norths
farm
zoo
tables
bed
chair
bowl
spoon
bottle
magazine
window
television
computer
radio
mirrors
clock
cellphone
watch
sofa
lamp
desk
basket
batteries
soap
bedsheets
wallet
door
box
tv
screen
razor
toothpaste
telephone
wall
floor
bag
wheel
umbrella
roof
cabinet
letter
key
pool
sponge
things
bell
scissors
glass
cup
phone
pan
paper
engine
object
machine
string
piece
sheets
motor
chain
flag
novel
powder
comb
through
fork
knife
toothbrush
person
babies
friend
boyfriend
girlfriend
public
enemy
committee
conference
cultures
foundation
population
youth
relationship
village
couple
citizen
victim
people
travel
travels
car
bicycle
suitcase
bus
train
motorcycles
boat
airplane
drive
backpack
guide
visit
spanish
portuguese
map
road
ship
vehicle
transportation
trip
italian
french
flight
adventure
bridge
plane
journey
german
departure
tourist
subway
America
France
passport
Germany
England
Europe
China
abroad
south
american
chinese
international
european
around
turn
turns
domestic
this
one
these
those
all
everybody
every
any
other
another
each
something
such
both
few
everything
none
someone
nothing
anything
everyone
anybody
nobody
everywhere
two
three
four
five
some
less
six
seven
eight
nine
ten
many
last
first
number
million
third
amount
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
thirty
forty
fifty
sixty
seventy
eighty
ninety
hundred
thousands
sum
majority
meter
pair
average
half
per
total
fourth
fifth
sixth
seventh
eighth
ninth
uses
contains
gets
respect
calls
agree
gives
appear
watches
count
looks
miss
lives
follows
fill
produce
reserve
appears
signs
mix
dry
import
helps
spend
supports
knows
continues
deliver
leaves
begins
presents
hate
assumes
tells
finds
counts
serves
creates
believes
adds
talks
visits
introduce
demands
feels
opens
explains
reserves
arrive
receives
wins
cuts
puts
thinks
produces
announce
wishes
fits
delivers
asks
tries
sing
put
allows
sets
studies
teacher
note
pens
school
program
education
library
test
application
examples
knowledge
training
class
word
chapter
practice
institute
idea
lecture
professor
presentation
preparation
explanation
difficulty
universities
course
college
objective
teaching
history
pages
report
documents
meaning
was
were
ate
drank
went
cooked
spoke
yesterday
walked
liked
wanted
loved
rained
touched
recently
played
heard
listened
saw
had
said
born
told
made
used
found
called
started
thought
lost
came
took
wrote
informed
gave
died
turned
tried
supported
decided
returned
looked
felt
knew
performed
kept
beat
introduced
won
happened
finished
reached
showed
entered
opened
seemed
appeared
explained
stopped
fell
answered
stayed
talked
watched
be
let
close
rent
rain
get
exercise
help
buy
add
set
learn
start
sell
create
keep
enter
did
happen
leave
broke
part
view
service
list
system
review
order
group
way
types
case
versions
members
control
account
profile
level
description
image
content
value
categories
act
equipment
problem
side
performance
options
activity
results
issue
agreement
solutions
protection
construction
response
kind
entry
effect
minds
union
opportunity
choice
degrees
matter
voice
evidence
role
purpose
success
awards
introduction
charge
grade
subject
alternative
record
edge
big
small
good
great
new
old
than
young
smaller
bigger
older
younger
prettier
free
best
full
long
large
cleaner
cheaper
hot
better
hard
able
short
bad
true
fast
clear
simple
nice
happy
strong
deep
poor
cold
rich
sweet
sharp
pure
worse
worst
weak
tall
alone
ready
sure
been
previously
eaten
spoken
previous
seen
since
paid
before
given
become
written
done
ago
received
taken
asked
sent
developed
presented
closed
changed
met
followed
prepared
forced
gone
reduced
ordered
lived
arrived
missed
allowed
known
drunk
passed
assumed
meet
cover
choose
increase
stay
build
continue
apply
though
allow
win
improve
cut
repeat
wake
understand
lets
develop
die
fit
accept
begin
avoid
prevent
serve
wait
define
reach
finish
achieve
exist
affect
explain
assume
respond
lose
forget
prepare
shut
belong
suffer
recover
analyze
whom
led
discovered
established
title
benefits
situation
religion
efforts
attention
interests
competition
life
load
permission
faith
truth
failure
signal
character
reality
origin
damages
secret
direction
lack
scene
aim
behavior
signature
attempt
instance
circle
exit
symbol
position
strength
experience
shape
relation
fear
permit
doubts
humor
possibilities
desire
existence
pleasure
responsibility
space
consequences
surprise
tradition
conversation
trend
fault
favor
phrases
attitude
murder
mistake
honor
smile
danger
joy
entrance
shadow
memories
himself
herself
itself
myself
yourself
ourselves
yourselves
themselves
flower
tree
grass
skies
sea
moon
sun
worlds
volcano
fire
airs
field
star
land
weather
nature
river
earth
mountain
wood
up
forest
stone
wind
heat
roses
planet
down
climate
universe
landscape
soil
smoke
crop
gas
material
plant
dust
sand
having
speaking
touching
making
following
including
getting
taking
trying
giving
thinking
talking
saying
waiting
watching
wearing
happening
studying
coming
walking
eating
drinking
going
swimming
looking
doing
reading
writing
raining
sleeping
seeing
cooking
running
paying
playing
working
starting
calling
leaving
sitting
ball
sport
team
player
step
paths
goal
points
game
scored
soccer
basketball
tennis
racket
volleyball
kick
jump
jumps
coach
match
marathons
exercises
gym
championship
athlete
violin
flute
music
camera
movies
picture
film
art
style
sound
figure
song
photography
dance
instrument
literature
fashion
theater
poetries
concert
contest
opening
painting
audience
collection
band
actress
musical
paint
search
information
comment
network
press
text
stories
channel
communication
news
message
internet
languages
postcard
stamps
access
journalist
sick
hand
eyes
health
care
body
head
emergency
treatment
heart
face
cancer
medicine
ambulance
blood
disease
hair
patients
hospital
operation
skin
foot
diet
vision
pain
drugs
virus
brain
arm
legs
mouth
dream
accident
neck
sight
illness
fingers
ears
chest
teeth
tongue
nose
lips
back
ill
conditions
appointment
nurse
will
break
receive
reduce
register
security
laws
government
tax
court
war
president
society
safety
advices
investment
vote
strategy
opinion
debt
progress
peace
economy
army
crime
leader
freedom
arguments
campaign
congress
election
queen
speech
violence
conflict
navies
candidates
threat
governor
senator
crisis
parliament
strike
mayor
wealth
blame
plans
decision
king
cause
weapon
arrest
prince
discover
establish
resolve
transport
research
line
details
technology
project
sizes
article
sciences
analysis
energy
edition
unit
weight
method
speed
volume
length
sample
distance
publication
theory
surface
definition
scales
temperatures
technique
masses
task
limits
quantities
laboratory
depth
height
physics
philosophy
measures
concepts
chemistry
discovery
formula
investigation
dots
scientist
geography
electric
cycle
conclusion
reasons
decrease
alcohol
created
chosen
money
dollars
business
products
board
insurance
sale
card
credit
industry
gold
trade
risks
brand
contracts
deal
budgets
agent
worth
currency
advertisement
promotion
prize
firm
advertising
cost
organizations
lot
costs
interview
meetings
company
price
check
global
can
cannot
could
must
would
should
action
delivery
discussion
death
stops
traffic
attack
battle
noises
occasion
birthdays
funeral
considered
managed
powers
quality
beauty
force
difference
identity
expressions
importance
luck
personality
advantage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment