Skip to content

Commit

Permalink
fix: issue NanmiCoder#140
Browse files Browse the repository at this point in the history
  • Loading branch information
NanmiCoder committed Feb 26, 2024
1 parent 67d2b7c commit 384c8f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions media_platform/douyin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async def search_info_by_keyword(
"count": 10 # must be set to 10
}
referer_url = "https://www.douyin.com/search/" + keyword
referer_url += f"?publish_time={publish_time.value}&sort_type={sort_type.value}&type=general"
headers = copy.copy(self.headers)
headers["Referer"] = urllib.parse.quote(referer_url, safe=':/')
return await self.get("/aweme/v1/web/general/search/single/", params, headers=headers)
Expand Down
5 changes: 4 additions & 1 deletion media_platform/douyin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .client import DOUYINClient
from .exception import DataFetchError
from .login import DouYinLogin
from .field import PublishTimeType


class DouYinCrawler(AbstractCrawler):
Expand Down Expand Up @@ -88,7 +89,9 @@ async def search(self) -> None:
while (page + 1) * dy_limit_count <= config.CRAWLER_MAX_NOTES_COUNT:
try:
posts_res = await self.dy_client.search_info_by_keyword(keyword=keyword,
offset=page * dy_limit_count)
offset=page * dy_limit_count,
publish_time=PublishTimeType.UNLIMITED
)
except DataFetchError:
utils.logger.error(f"[DouYinCrawler.search] search douyin keyword: {keyword} failed")
break
Expand Down

0 comments on commit 384c8f9

Please sign in to comment.