Set urllib useragent string.

- Use a custom string to help with identifying traffic
- Update version to 0.1.12
- Small linting

Adjust the user agent string, lint
pull/14/merge
macmenot 11 years ago committed by Richard Harding
parent 75b3151de9
commit 4f2b744a3a

@ -1,3 +1,3 @@
VERSION = '0.1.11'
VERSION = '0.1.12'
import client
from scripts import newtest

@ -15,20 +15,34 @@ from breadability.readable import Article
LOGLEVEL = 'WARNING'
USER_AGENT = 'breadability /{version} ({url})'.format(
url="https://github.com/mitechie/breadability",
version=VERSION
)
# Setup a user agent on the requests out so that we make servers happy. We use
# a custom agent string to help assist others in identifying the traffic.
class AppURLopener(urllib.FancyURLopener):
version = USER_AGENT
urllib._urlopener = AppURLopener()
def parse_args():
desc = "A fast python port of arc90's readability tool"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--version',
parser.add_argument(
'--version',
action='version', version=VERSION)
parser.add_argument('-v', '--verbose',
parser.add_argument(
'-v', '--verbose',
action='store_true',
default=False,
help='Increase logging verbosity to DEBUG.')
parser.add_argument('-f', '--fragment',
parser.add_argument(
'-f', '--fragment',
action='store_false',
default=True,
help='Output html fragment by default.')
@ -38,17 +52,22 @@ def parse_args():
# default=False,
# help='print all metadata as well as content for the content')
parser.add_argument('-b', '--browser',
parser.add_argument(
'-b', '--browser',
action='store_true',
default=False,
help='open the parsed content in your web browser')
parser.add_argument('-d', '--debug',
parser.add_argument(
'-d', '--debug',
action='store_true',
default=False,
help='Output the detailed scoring information for debugging parsing')
parser.add_argument('path', metavar='P', type=str, nargs=1,
parser.add_argument(
'path', metavar='P',
type=str,
nargs=1,
help="The url or file path to process in readable form.")
args = parser.parse_args()
@ -91,7 +110,7 @@ def main():
else:
# Wrap sys.stdout into a StreamWriter to allow writing unicode.
sys.stdout = codecs.getwriter(
locale.getpreferredencoding())(sys.stdout)
locale.getpreferredencoding())(sys.stdout)
sys.stdout.write(doc.readable)

Loading…
Cancel
Save