GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-readability/main.py at master · initc/python-readability Expand file tree/ Copy pathmain.pyMore file actions 39 lines (36 loc) · 1.1 KB / Copy pathmain.pyFile metadata and controls39 lines (36 loc) · 1.1 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #!-*-coding:utf-8-*- import requests import os import hashlib import argparse from readability import Document #url = "https://www.quantamagazine.org/new-bird-species-arises-from-hybrids-as-scientists-watch-20171213/" #response = requests.get(url) SAVE_DIR = os.path.join(os.path.dirname(__name__), "html", "result") def parse_summary(filename=None,url=None): if filename: with open(filename,"r") as f: html = f.read() n = "content_%s"%os.path.basename(filename) if url: html = requests.get(url).text n = "url_content_%s_.html"%hashlib.md5(url.encode("utf-8")).hexdigest()[0:6] doc = Document(html) summary = doc.summary() fn = os.path.join(SAVE_DIR, n) with open(fn, 'w') as f: f.write(summary) if __name__ == "__main__": parse = argparse.ArgumentParser() parse.add_argument('-f',"--file",help="set file to parse") parse.add_argument("-l", "--url", help="set url link to parse") args = parse.parse_args() if args.file: filename = args.file parse_summary(filename=filename) print("parse success") else : if args.url: url = args.url parse_summary(url=url) print("parse success") |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |