add 'like' function
This commit is contained in:
parent
4c861f0c7a
commit
2e884c6ab7
3 changed files with 16 additions and 2 deletions
|
@ -12,7 +12,7 @@ async def parse_cmd():
|
||||||
parser.add_argument('--lt', type=str, help='Login type (qrcode | phone | cookie)',
|
parser.add_argument('--lt', type=str, help='Login type (qrcode | phone | cookie)',
|
||||||
choices=["qrcode", "phone", "cookie"], default=config.LOGIN_TYPE)
|
choices=["qrcode", "phone", "cookie"], default=config.LOGIN_TYPE)
|
||||||
parser.add_argument('--type', type=str, help='crawler type (search | detail | creator)',
|
parser.add_argument('--type', type=str, help='crawler type (search | detail | creator)',
|
||||||
choices=["search", "detail", "creator", "explore"], default=config.CRAWLER_TYPE)
|
choices=["search", "detail", "creator", "explore","test"], default=config.CRAWLER_TYPE)
|
||||||
parser.add_argument('--start', type=int,
|
parser.add_argument('--start', type=int,
|
||||||
help='number of start page', default=config.START_PAGE)
|
help='number of start page', default=config.START_PAGE)
|
||||||
parser.add_argument('--keywords', type=str,
|
parser.add_argument('--keywords', type=str,
|
||||||
|
|
|
@ -340,7 +340,14 @@ class XiaoHongShuClient(AbstractApiClient):
|
||||||
id = tmp_list[2]
|
id = tmp_list[2]
|
||||||
explore_id.append(id)
|
explore_id.append(id)
|
||||||
return explore_id
|
return explore_id
|
||||||
|
|
||||||
|
async def like_note(self, note_oid: str) -> Dict:
|
||||||
|
uri = "/api/sns/web/v1/note/like"
|
||||||
|
data = {
|
||||||
|
"note_oid": note_oid
|
||||||
|
}
|
||||||
|
return await self.post(uri, data)
|
||||||
|
|
||||||
async def get_creator_info(self, user_id: str) -> Dict:
|
async def get_creator_info(self, user_id: str) -> Dict:
|
||||||
"""
|
"""
|
||||||
通过解析网页版的用户主页HTML,获取用户个人简要信息
|
通过解析网页版的用户主页HTML,获取用户个人简要信息
|
||||||
|
|
|
@ -83,6 +83,8 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
||||||
await self.get_creators_and_notes()
|
await self.get_creators_and_notes()
|
||||||
elif config.CRAWLER_TYPE == "explore":
|
elif config.CRAWLER_TYPE == "explore":
|
||||||
await self.get_explore()
|
await self.get_explore()
|
||||||
|
elif config.CRAWLER_TYPE == "test":
|
||||||
|
await self.like()
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -130,6 +132,11 @@ class XiaoHongShuCrawler(AbstractCrawler):
|
||||||
except DataFetchError:
|
except DataFetchError:
|
||||||
utils.logger.error("[XiaoHongShuCrawler.search] Get note detail error")
|
utils.logger.error("[XiaoHongShuCrawler.search] Get note detail error")
|
||||||
break
|
break
|
||||||
|
async def like(self) -> None:
|
||||||
|
note_oid = "65f54b1c0000000012022342"
|
||||||
|
ret_v = await self.xhs_client.like_note(note_oid)
|
||||||
|
print(ret_v)
|
||||||
|
|
||||||
async def get_explore(self) -> None:
|
async def get_explore(self) -> None:
|
||||||
explore_id = await self.xhs_client.get_explore_id()
|
explore_id = await self.xhs_client.get_explore_id()
|
||||||
print("[+]GET explore content:")
|
print("[+]GET explore content:")
|
||||||
|
|
Loading…
Reference in a new issue