Skip to content

Instantly share code, notes, and snippets.

@vim13
Created September 29, 2010 20:33
Show Gist options
  • Save vim13/603502 to your computer and use it in GitHub Desktop.
Save vim13/603502 to your computer and use it in GitHub Desktop.
cookpad
#!/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