Skip to content

Instantly share code, notes, and snippets.

@qsun
Created April 13, 2012 00:23
Show Gist options
  • Save qsun/2372218 to your computer and use it in GitHub Desktop.
Save qsun/2372218 to your computer and use it in GitHub Desktop.
parse amazon kindle share page
from bs4 import BeautifulSoup
import urllib2
def parse_url(url):
bs = BeautifulSoup(urllib2.urlopen(url))
items = []
for i in bs.find_all('li', {'class': 'recentActivityEntry'}):
id = i['id']
url = 'https://kindle.amazon.com' + i.find('a')['href']
content = i.find('span', {'class': 'sampleCloseQuote'}).get_text()
items.append({'id': id, 'url': url, 'content': content})
return items
if '__main__' == __name__:
print parse_url(
'https://kindle.amazon.com/profile/Quan-Sun/1093285'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment