如何使用 Twint 从特定年份和特定位置抓取推特数据
How to scrape twitter data from specific years and specific locations using Twint
import twint
import nest_asyncio
import pandas as pd
nest_asyncio.apply()
c = twint.Config()
c.Search = "Covid-19"
twint.run.Search(c)
上面的代码收集了带有 covid-19 一词的推文,但我只想要去年和特定位置的推文?
您可以在搜索字符串中添加时间范围,如下所示:
searchstr = "(Covid-19) until:2021-02-19 since:2021-02-17)"
c.Search = searchstr
Source
要指定位置,您可以将其添加到搜索字符串中
geocode:latitude,longitude,radius
例如:
geocode:43.913723261972855,-72.54272478125,150km
https://thoughtfaucet.com/search-twitter-by-location/examples/
import twint
import nest_asyncio
import pandas as pd
nest_asyncio.apply()
c = twint.Config()
c.Search = "Covid-19"
twint.run.Search(c)
上面的代码收集了带有 covid-19 一词的推文,但我只想要去年和特定位置的推文?
您可以在搜索字符串中添加时间范围,如下所示:
searchstr = "(Covid-19) until:2021-02-19 since:2021-02-17)"
c.Search = searchstr
Source
要指定位置,您可以将其添加到搜索字符串中
geocode:latitude,longitude,radius
例如:
geocode:43.913723261972855,-72.54272478125,150km
https://thoughtfaucet.com/search-twitter-by-location/examples/