diff options
author | Sergey M․ <dstftw@gmail.com> | 2016-09-15 21:54:48 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2016-09-15 21:54:48 +0700 |
commit | c8498368549048a578d5f30773aaa9760454983c (patch) | |
tree | 16892209c4aef537c238e0f4786557876c46796d /youtube_dl/extractor | |
parent | eb5b1fc0211e89f386c4f5563cc1d5d4edeb3c55 (diff) |
[utils] Improve _hidden_inputs
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/common.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index ff19270ae..e413799f9 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -888,16 +888,16 @@ class InfoExtractor(object): def _hidden_inputs(html): html = re.sub(r'<!--(?:(?!<!--).)*-->', '', html) hidden_inputs = {} - for input in re.findall(r'(?i)<input([^>]+)>', html): - if not re.search(r'type=(["\'])(?:hidden|submit)\1', input): + for input in re.findall(r'(?i)(<input[^>]+>)', html): + attrs = extract_attributes(input) + if not input: continue - name = re.search(r'(?:name|id)=(["\'])(?P<value>.+?)\1', input) - if not name: + if attrs.get('type') not in ('hidden', 'submit'): continue - value = re.search(r'value=(["\'])(?P<value>.*?)\1', input) - if not value: - continue - hidden_inputs[name.group('value')] = value.group('value') + name = attrs.get('name') or attrs.get('id') + value = attrs.get('value') + if name and value is not None: + hidden_inputs[name] = value return hidden_inputs def _form_hidden_inputs(self, form_id, html): |