Created
September 29, 2010 20:33
-
-
Save vim13/603502 to your computer and use it in GitHub Desktop.
cookpad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/lib/python | |
#vim:fileencoding=utf-8 | |
import urllib2 | |
import re | |
from BeautifulSoup import BeautifulSoup | |
class Cookpad: | |
def __init__(self): | |
url = 'http://cookpad.com/recipe/recent' | |
self.soup = BeautifulSoup(urllib2.urlopen(url)) | |
def recipe(self): | |
node = self.soup.find('div', {'class': 'recipe-text'}) | |
tag = node('a', {'class': 'recipe-title font13'}) | |
res = re.search(u'href="(.*?)".*?>(.*?)</a>', str(tag[0])) | |
return res.group(1), res.group(2) | |
if __name__ == '__main__': | |
obj = Cookpad() | |
obj.recipe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment