首页 > 解决方案 > Python 中的 TwitterAPI - 如何仅从一个国家/地区返回推文?

问题描述

我正在使用 Python 中的 TwitterAPI 使用一些关键字访问 Twitter 上的完整推文存档。我在文档中读到,我可以使用 place_country 和国家代码指定位置,但由于某种原因,它不会只返回那个国家的结果。如何从按国家/地区过滤的完整档案中获取推文?

from TwitterAPI import TwitterAPI

r = api.request("tweets/search/fullarchive/:cs",
{"query":"Corona place_country:DE", 
"maxResults": "100", 
"fromDate":"201908230000", 
"toDate":"202004300000"})

标签: pythonpython-requeststwitter-oauthtwitterapi-python

解决方案


I don't think it's possible this way, place_country is not a field that you can use from the standard search api (https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets).

You can probably use "geocode" with a large "radius" and "lang" parameter.


推荐阅读