Find rhyming words


/ Published in: Python
Save to your folder(s)

needs external library lxml


Copy this code and paste it in your HTML
  1. import urllib
  2. from lxml.html import fromstring
  3.  
  4. def getRhymes(word):
  5. url = 'http://www.rhymer.com/RhymingDictionary/%s.html' % word
  6. doc = fromstring(urllib.urlopen(url).read())
  7. for i in doc.find_class('blue'):
  8. items = i.xpath('tr/td/a')
  9. return [hmm.text for hmm in items]

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.