-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (26 loc) · 821 Bytes
/
main.py
File metadata and controls
36 lines (26 loc) · 821 Bytes
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
#!/usr/local/bin/python2.7
import sys
from bs4 import BeautifulSoup
import urllib2
import nltk
URL = "http://well.blogs.nytimes.com/projects/healthy-recipes/recipes/quinoa-salad-with-avocado-and-kalamata-olives"
def get_movie_data():
# Download IMDB dat
""""""
def main():
"Open URL"
page = urllib2.urlopen(URL)
soup = BeautifulSoup(page)
x = soup.find('div', attrs={'class' : 'ingredients left'})
y = x.find_all('li', attrs={'itemprop': 'ingredients'})
keys = ['NN','JJ','VBP']
for item in y:
ingred = item.text
tokens = nltk.word_tokenize(ingred)
tagged = nltk.pos_tag(tokens)
#print tagged
for word in tagged:
if word[1] in keys:
print word
if __name__ == '__main__':
sys.exit(main())