Created
December 5, 2014 16:54
-
-
Save kamotos/250a650ddd240e52289b to your computer and use it in GitHub Desktop.
Text extraction
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
beautifulsoup4==4.3.2 | |
python-readability | |
requests |
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
import bs4 | |
import requests | |
from readability import readability | |
def get_summary(url): | |
response = requests.get(url) | |
document = readability.Document(response.content) | |
body = bs4.BeautifulSoup(document.summary()).get_text() | |
return {'text': body, 'title': document.short_title()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment