[naver] simplify code + add test
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
from .common import GalleryExtractor, Extractor, Message
|
||||
from .. import text
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
class NaverBase():
|
||||
@@ -63,16 +62,13 @@ class NaverPostExtractor(NaverBase, GalleryExtractor):
|
||||
return data
|
||||
|
||||
def images(self, page):
|
||||
return [
|
||||
(unquote(url, encoding="EUC-KR")
|
||||
.replace("://post", "://blog", 1)
|
||||
.partition("?")[0], None)
|
||||
if "\ufffd" in unquote(url)
|
||||
else
|
||||
(url.replace("://post", "://blog", 1)
|
||||
.partition("?")[0], None)
|
||||
for url in text.extract_iter(page, 'data-lazy-src="', '"')
|
||||
]
|
||||
results = []
|
||||
for url in text.extract_iter(page, 'data-lazy-src="', '"'):
|
||||
url = url.replace("://post", "://blog", 1).partition("?")[0]
|
||||
if "\ufffd" in text.unquote(url):
|
||||
url = text.unquote(url, encoding="EUC-KR")
|
||||
results.append((url, None))
|
||||
return results
|
||||
|
||||
|
||||
class NaverBlogExtractor(NaverBase, Extractor):
|
||||
|
||||
Reference in New Issue
Block a user