Skip to content

Instantly share code, notes, and snippets.

@kimmel
Created August 26, 2012 18:08
Show Gist options
  • Save kimmel/3482211 to your computer and use it in GitHub Desktop.
Save kimmel/3482211 to your computer and use it in GitHub Desktop.
python Beautiful Soup regexp 1
from datetime import datetime
import BeautifulSoup as soup
import requests
...
r = requests.get(host + page)
doc = soup.BeautifulSoup(r.content)
titles = doc.table.findAll(True, {'class': 'title'})
articles = titles[:-1]
for no, title in chunks(articles, 2):
acc.append( (title.a.string, title.a['href']) )
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment