Skip to content

Commit

Permalink
MOD:utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
ShilongLee committed Jul 29, 2024
1 parent 07fc90e commit 4c208d7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion service/douyin/logic/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dnt": "1",
}

DOUYIN_SIGN = execjs.compile(open('lib/js/douyin.js').read())
DOUYIN_SIGN = execjs.compile(open('lib/js/douyin.js', encoding='utf-8').read())

async def get_webid(headers: dict):
url = 'https://www.douyin.com/?recommend=1'
Expand Down
4 changes: 2 additions & 2 deletions service/xhs/logic/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def common_request(uri: str, params: dict, headers: dict, need_sign: bool

if post:
if need_sign:
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js').read())
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js', encoding='utf-8').read())
sign_header = xhs_sign_obj.call('sign', uri, params, headers.get('cookie', ''))
headers.update(sign_header)

Expand All @@ -54,7 +54,7 @@ async def common_request(uri: str, params: dict, headers: dict, need_sign: bool
url = f'{url}?{params_str}'

if need_sign:
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js').read())
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js', encoding='utf-8').read())
sign_header = xhs_sign_obj.call('sign', uri, None, headers.get('cookie', ''))
headers.update(sign_header)

Expand Down
2 changes: 1 addition & 1 deletion service/xhs/logic/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async def request_search(keyword: str, cookie: str, offset: int = 0, limit: int
page_size = 20
start_page = int( offset / page_size ) + 1
end_page = int((offset + limit - 1) / page_size) + 1
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js').read())
xhs_sign_obj = execjs.compile(open('lib/js/xhs.js', encoding='utf-8').read())
tasks = [request_page(page, keyword, cookie, page_size, xhs_sign_obj) for page in range(start_page, end_page + 1)]
pages = await asyncio.gather(*tasks)
results = []
Expand Down

0 comments on commit 4c208d7

Please sign in to comment.