Original Post
from urllib2 import *
print "Enter a word, and this program will find its definition."
word = raw_input()
dict_url = "http://dictionary.reference.com/search?q=" + word
for line in urlopen(dict_url):
if '< ! - - begin ahd4 - - > ' in line: #look for comment
#this is the part where I get confused
I want to write a program that allows me to get the definitions of words off of Dictionary.com. I found out that the website conveniently inserts comment tags to mark off the definition, so I decided to test out my new Python skills and tried to write a program that would retrieve the definition for me. Unfortunately, I'm having some troubles. After I check if the comment beginning delimiter (< ! - - begin ahd4 - - >) is in the line, I want to keep printing lines until the ending delimiter is met (< ! - - end ahd4 - - >). Unfortunately, this usually ends in an infinite loop, or something of the sort. I'm not sure how to get it to print only what is between the two comment lines. I've tried putting a loop that says something like while not '< ! - - end ahd4 - - >' in line:, but that doesn't work. Can someone please help me? EDIT: I had to put spaces in the comment tags, otherwise they wouldn't show up.