https://github.com/norton120/mediummuncher
package for extracting content from Medium stories and feeds
https://github.com/norton120/mediummuncher
Last synced: 4 months ago
JSON representation
package for extracting content from Medium stories and feeds
- Host: GitHub
- URL: https://github.com/norton120/mediummuncher
- Owner: norton120
- Created: 2019-12-08T22:17:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-26T16:16:22.000Z (over 1 year ago)
- Last Synced: 2025-03-13T08:55:44.792Z (about 1 year ago)
- Language: Python
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Medium Muncher
Medium makes content readily available for machine consumption through the `format=json` param, and content feeds via the `feeds` path, however the XML and JSON responses are not exactly plug-and-play for redisplaying content. Enter this package.
### Installation
via pip with
```
pip3 install mediummuncher
```
### Usage
Getting a story as stand-alone HTML (with head and body tags)
```
from medium_muncher import MediumMuncher
muncher = MediumMuncher()
full_html=muncher.munch_story('https://medium.com/some-author/some-amazing-article-039525')
#returns "... "
```
Getting a story as an html snippet (no head or body)
```
html_snippet=muncher.munch_story('https://medium.com/some-author/some-amazing-article-039525',snippet=True)
#returns "
article text!..."
```
Using the `verbose` flag returns a tuple with the html and a dictionary of interesting article attributes such as title, published date etc.
```
html_snippet=muncher.munch_story('https://medium.com/some-author/some-amazing-article-039525',snippet=True, verbose=True)
#returns tuple ("
article text!...", {"title":"this amazing article"...,)
```
Getting all the story urls for a given author
```
stories=muncher.munch_author_feed('some-author')
#returns tuple ("https://medium.com/some-author/amazing-article-one-12902990",..,)
```
Putting it all together to extract all stories for a given author
```
stories=list()
for url in muncher.munch_author_feed('ethan.m.knox'):
stories.append(muncher.munch_story( url,
snippet=True,
verbose=True))
print(list)
```
## Contributing
Please feel free to fork and PR! Can always use another helping hand.