зеркало из
https://github.com/viginum-datalab/twscrape.git
synced 2025-10-29 05:04:22 +02:00
update readme on how to change search tab
Этот коммит содержится в:
родитель
6a232da016
Коммит
d0fbef5b0c
1
Makefile
1
Makefile
@ -63,6 +63,7 @@ test-sq-matrix:
|
|||||||
@make test-sq y=2020 v=3330000
|
@make test-sq y=2020 v=3330000
|
||||||
@make test-sq y=2021 v=3340100
|
@make test-sq y=2021 v=3340100
|
||||||
@make test-sq y=2023 v=3430000
|
@make test-sq y=2023 v=3430000
|
||||||
|
@make test-sq y=2023 v=3440000
|
||||||
|
|
||||||
update-mocks:
|
update-mocks:
|
||||||
twscrape user_by_id --raw 2244994945 | jq > ./tests/mocked-data/user_by_id_raw.json
|
twscrape user_by_id --raw 2244994945 | jq > ./tests/mocked-data/user_by_id_raw.json
|
||||||
|
|||||||
@ -77,6 +77,8 @@ async def main():
|
|||||||
|
|
||||||
# search (latest tab)
|
# search (latest tab)
|
||||||
await gather(api.search("elon musk", limit=20)) # list[Tweet]
|
await gather(api.search("elon musk", limit=20)) # list[Tweet]
|
||||||
|
# change search tab (product), can be: Top, Latest (default), Media
|
||||||
|
await gather(api.search("elon musk", limit=20, kv={"product": "Top"}))
|
||||||
|
|
||||||
# tweet info
|
# tweet info
|
||||||
tweet_id = 20
|
tweet_id = 20
|
||||||
|
|||||||
@ -189,25 +189,20 @@ class Tweet(JSONTrait):
|
|||||||
def parse(obj: dict, res: dict):
|
def parse(obj: dict, res: dict):
|
||||||
tw_usr = User.parse(res["users"][obj["user_id_str"]])
|
tw_usr = User.parse(res["users"][obj["user_id_str"]])
|
||||||
|
|
||||||
rt_id = _first(
|
rt_id_path = [
|
||||||
obj,
|
"retweeted_status_id_str",
|
||||||
[
|
"retweeted_status_result.result.rest_id",
|
||||||
"retweeted_status_id_str",
|
"retweeted_status_result.result.tweet.rest_id",
|
||||||
"retweeted_status_result.result.rest_id",
|
]
|
||||||
"retweeted_status_result.result.tweet.rest_id"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
rt_obj = get_or(res, f"tweets.{rt_id}")
|
|
||||||
|
|
||||||
qt_id = _first(
|
qt_id_path = [
|
||||||
obj,
|
"quoted_status_id_str",
|
||||||
[
|
"quoted_status_result.result.rest_id",
|
||||||
"quoted_status_id_str",
|
"quoted_status_result.result.tweet.rest_id",
|
||||||
"quoted_status_result.result.rest_id"
|
]
|
||||||
"quoted_status_result.result.tweet.rest_id"
|
|
||||||
]
|
rt_obj = get_or(res, f"tweets.{_first(obj, rt_id_path)}")
|
||||||
)
|
qt_obj = get_or(res, f"tweets.{_first(obj, qt_id_path)}")
|
||||||
qt_obj = get_or(res, f"tweets.{qt_id}")
|
|
||||||
|
|
||||||
doc = Tweet(
|
doc = Tweet(
|
||||||
id=int(obj["id_str"]),
|
id=int(obj["id_str"]),
|
||||||
|
|||||||
Загрузка…
x
Ссылка в новой задаче
Block a user