Compare commits

..

No commits in common. "9815794a9712087ea985a3cf427be90751a7aff8" and "2fe3e0b8ee15ac99025f1e4ebca8b147f97be1e1" have entirely different histories.

4 changed files with 19 additions and 25 deletions

View File

@ -221,7 +221,7 @@ class GZIPHandler(BaseHandler):
def detect_encoding(data, resp=None):
enc = detect_raw_encoding(data, resp)
if enc.lower() == 'gb2312':
if enc == 'gb2312':
enc = 'gbk'
return enc
@ -261,8 +261,12 @@ class EncodingFixHandler(BaseHandler):
if 200 <= resp.code < 300 and maintype == 'text':
data = resp.read()
enc = self.encoding or detect_encoding(data, resp)
if not self.encoding:
enc = detect_encoding(data, resp)
else:
enc = self.encoding
if enc:
data = data.decode(enc, 'replace')
data = data.encode(enc)
@ -651,8 +655,5 @@ class MySQLCacheHandler(BaseCache):
if __name__ == '__main__':
req = adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
if sys.flags.interactive:
print('>>> Interactive shell: try using `req`')
else:
if not sys.flags.interactive:
print(req['data'].decode(req['encoding']))

View File

@ -780,9 +780,6 @@ if __name__ == '__main__':
req = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://www.nytimes.com/', follow='rss')
feed = parse(req['data'], url=req['url'], encoding=req['encoding'])
if sys.flags.interactive:
print('>>> Interactive shell: try using `feed`')
else:
if not sys.flags.interactive:
for item in feed.items:
print(item.title, item.link)

View File

@ -351,8 +351,5 @@ if __name__ == '__main__':
req = crawler.adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')
article = get_article(req['data'], url=req['url'], encoding_in=req['encoding'], encoding_out='unicode')
if sys.flags.interactive:
print('>>> Interactive shell: try using `article`')
else:
if not sys.flags.interactive:
print(article)

View File

@ -33,8 +33,7 @@
}
header {
text-align: justify;
text-align-last: center;
text-align: center;
border-bottom: 1px solid silver;
}
@ -113,6 +112,7 @@
}
header > form {
text-align: center;
margin: 1%;
}
@ -176,7 +176,7 @@
<select>
<option value="">full-text</option>
<option value=":proxy">original</option>
<option value=":clip" title="original + full-text: keep the original description above the full article. Useful for reddit feeds for example, to keep the comment links">combined (?)</option>
<option value=":clip">original + full-text</option>
</select>
feed as
<select>
@ -185,12 +185,12 @@
<option value=":html">HTML</option>
<option value=":csv">CSV</option>
</select>
using the
using
<select>
<option value="">standard</option>
<option value=":firstlink" title="Pull the article from the first available link in the description, instead of the standard link. Useful for Twitter feeds for example, to get the articles referred to in tweets rather than the tweet itself">first (?)</option>
<option value="">the standard link</option>
<option value=":firstlink" title="Useful for Twitter feeds for example, to get the articles referred to in tweets rather than the tweet itself">the first link from the description (?)</option>
</select>
link and
and
<select>
<option value="">keep</option>
<option value=":nolink:noref">remove</option>
@ -199,8 +199,7 @@
<input type="hidden" value="" name="extra_options"/>
</form>
<p>You can find a <em>preview</em> of the feed below. You need a <em>feed reader</em> for optimal use</p>
<p>Click <a href="/">here</a> to go back to morss and/or to use the tool on another feed</p>
<p>Click <a href="/">here</a> to go back to morss</p>
</header>
<div id="header" dir="auto">