fix: missing chunk, fr this time
This commit is contained in:
@@ -27,6 +27,7 @@ class Scraper(ClientSession):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# 모바일 페이지 및 첨부 파일 요청 시 필요한 기본 헤더 값
|
# 모바일 페이지 및 첨부 파일 요청 시 필요한 기본 헤더 값
|
||||||
|
self.headers['Accept'] = '*/*'
|
||||||
self.headers['User-Agent'] = '(Android)'
|
self.headers['User-Agent'] = '(Android)'
|
||||||
self.headers['Referer'] = 'https://m.dcinside.com/board/aoegame'
|
self.headers['Referer'] = 'https://m.dcinside.com/board/aoegame'
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ class Scraper(ClientSession):
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Post(
|
Post(
|
||||||
id=int(re.findall(r'/\d+', tag.select_one('a[href]:first-child')['href'])[0][1:]),
|
id=int(re.findall(r'/\d+', tag.select_one('a[href]')['href'])[0][1:]),
|
||||||
board_id=board_id,
|
board_id=board_id,
|
||||||
board_path=board_path
|
board_path=board_path
|
||||||
)
|
)
|
||||||
@@ -182,7 +183,6 @@ class Scraper(ClientSession):
|
|||||||
|
|
||||||
:param url: 받아올 첨부 파일의 주소
|
:param url: 받아올 첨부 파일의 주소
|
||||||
:param save_dir: 받아질 로컬 디렉터리 경로
|
:param save_dir: 받아질 로컬 디렉터리 경로
|
||||||
:param chunk_size: 청크 크기
|
|
||||||
"""
|
"""
|
||||||
url_parsed = urlparse.urlparse(url)
|
url_parsed = urlparse.urlparse(url)
|
||||||
url_params = urlparse.parse_qs(url_parsed.query)
|
url_params = urlparse.parse_qs(url_parsed.query)
|
||||||
@@ -206,6 +206,7 @@ class Scraper(ClientSession):
|
|||||||
async for chunk, _ in response.content.iter_chunks():
|
async for chunk, _ in response.content.iter_chunks():
|
||||||
temp_file.write(chunk)
|
temp_file.write(chunk)
|
||||||
hash.update(chunk)
|
hash.update(chunk)
|
||||||
|
temp_file.flush()
|
||||||
|
|
||||||
# Content-Type 헤더로부터 확장자 알아내기
|
# Content-Type 헤더로부터 확장자 알아내기
|
||||||
attachment.source_suffix = mimetypes.guess_extension(response.content_type)
|
attachment.source_suffix = mimetypes.guess_extension(response.content_type)
|
||||||
@@ -239,6 +240,8 @@ class Scraper(ClientSession):
|
|||||||
urls = [
|
urls = [
|
||||||
# 이미지
|
# 이미지
|
||||||
*[
|
*[
|
||||||
|
# 움짤은 자동 변환 후 `data-gif`와 `data-mp4`로 반환됨
|
||||||
|
# TODO: bad code, clean shit up
|
||||||
tag.attrs.get('data-mp4', tag['data-original']).strip()
|
tag.attrs.get('data-mp4', tag['data-original']).strip()
|
||||||
for tag in post.body.select('img[data-original]')
|
for tag in post.body.select('img[data-original]')
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user