/ Published in: Python
needs external library lxml
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import urllib from lxml.html import fromstring def getRhymes(word): url = 'http://www.rhymer.com/RhymingDictionary/%s.html' % word doc = fromstring(urllib.urlopen(url).read()) for i in doc.find_class('blue'): items = i.xpath('tr/td/a') return [hmm.text for hmm in items]