【问题标题】:How to fix Twint to get all tweets through a specified date range?如何修复 Twint 以在指定日期范围内获取所有推文?
【发布时间】:2022-08-20 02:07:19
【问题描述】:

目前,我正在尝试使用 python 使用来自 twitter 的单词标准来抓取 \'2015-02-01 00:00:00\' 和 \'2022-05-04 00:00:00\' 之间的所有推文。但是,我的输出从 2022-05-03 23:58:59 开始,到 2022-04-25 13:15:04 结束。

import twint
import nest_asyncio
import pandas as pd
nest_asyncio.apply()


c = twint.Config()
c.Store_csv = True
c.User_full = True
search = [\'#Pets OR #People OR Pets OR People\']
c.Search = search
c.Since = \'2015-02-01 00:00:00\'

c.Until = \'2022-05-04 00:00:00\'
c.Pandas = True
twint.run.Search(c)

df = twint.storage.panda.Tweets_df

我的输出看起来像这样,其中 \"....\" 是日期范围之间的其他推文。

输出:

1521640495159693314 2022-05-03 23:58:59 +0000 <vtv> @jeff #Pets
....
....
....
1518579343643004928 2022-04-25 13:15:04 +0000 <> #People; 

    标签: python twint


    【解决方案1】:

    您应该尝试取出大括号并将字符串与关键字直接放在一起:

    import twint
    import nest_asyncio
    import pandas as pd
    nest_asyncio.apply()
    
    
    c = twint.Config()
    c.Store_csv = True
    c.User_full = True
    c.Search ='#Pets OR #People OR Pets OR People'
    c.Since = '2015-02-01 00:00:00'
    
    c.Until = '2022-05-04 00:00:00'
    c.Pandas = True
    twint.run.Search(c)
    
    df = twint.storage.panda.Tweets_df
    

    【讨论】:

      猜你喜欢
      • 2011-11-07
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      • 2012-02-26
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      相关资源
      最近更新 更多