Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4623cc0

Browse files
committed
v1.1.3
1 parent d64064b commit 4623cc0

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# urlsresolver v1.1.1
1+
# urlsresolver v1.1.3
22
Python urls resolver library with meta refresh support.
33

44
You can expand real address of any shortened url with `urlsresolver.resolve_url(url)` function.

‎urlsresolver/__init__.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
from urlparse import urljoin
77

8-
__version__ = (1, 1, 2)
8+
__version__ = (1, 1, 3)
99
__author__ = 'Alexandr Shurigin (https://github.com/phpdude/)'
1010

1111
# HTML tags syntax http://www.w3.org/TR/html-markup/syntax.html
@@ -64,6 +64,9 @@ def resolve_url(
6464
s = requests.session()
6565

6666
urls_history = OrderedDict()
67+
# disable compression for streamed requests.
68+
s.headers['Accept-Encoding'] = ''
69+
6770
if user_agent:
6871
s.headers['User-Agent'] = user_agent
6972

@@ -97,7 +100,13 @@ def follow_meta_redirects(url, max_redirects, **kwargs):
97100
if redirect:
98101
m = re.search('url\s*=\s*([^\s;]+)', redirect, re.I)
99102
if m:
100-
real_url = follow_meta_redirects(urljoin(resp.url, m.group(1)), max_redirects)
103+
m = m.group(1)
104+
105+
# fixing case url='#url here#'
106+
if m.startswith(('"', "'")) and m.endswith(('"', "'")):
107+
m = m[1:-1]
108+
109+
real_url = follow_meta_redirects(urljoin(resp.url, m), max_redirects)
101110

102111
urls_history[real_url] = True
103112

‎urlsresolver/__main__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
args.add_argument('-A', '--user-agent', help='Custom user agent')
1414
args.add_argument('-S', '--chunk-size', default=1500, metavar='SIZE',
1515
help='Length of fetched html block for testing meta redirects. Default 1500')
16-
args.add_argument('-H', '--history', help='Print redirection history', action='store_true')
1716
args.add_argument(
1817
'--remove_noscript',
1918
action='store_true',

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /