我用推特刮板下载了一些关于上次体育赛事的推特。不幸的是,由于研究的性质,我不能回去修改我的刮板,因为事件不会再次发生。推文分为几个类别,如时间戳、创建日期等
这些tweet存储在JSON文件中,我目前正在将它们导出到pandas
我关注的是每条推文细节中的文本和扩展的推文类别
不久前,Twitter允许用户发布更长的推文。当涉及到抓取推特数据时,如果推特在初始字符限制(140?我相信)以下,那么整个推特的文本将显示在文本类别中,没有任何问题,这正是我未来研究所需要的
但是,任何超过字符限制的推文在“文本”类别中显示如下:
@thedamon @getify I worry adding new terms add complexity and may make it harder for people to learn JavaScript. A… <url>
StackOverflow不允许我显示下面的短URL,但本质上,正如我刚才所说,它是完整帖子的短twitter URL
如您所见,文本以“…”结尾,后跟链接。 要查看全文,我需要查看“extended_tweet”类别,然后将信息放在如下位置:
{'full_text': '@thedamon @getify I worry adding new terms add complexity and may make it harder for people to learn JavaScript. A sort function is a function you send to sort. Learning a new acronym to abstract that adds unnecessary complexity.', 'display_text_range': [18, 229], 'entities': {'hashtags': [], 'urls': [], 'user_mentions': [{'screen_name': 'thedamon', 'name': 'Damon Muma', 'id': 29938474, 'id_str': '29938474', 'indices': [0, 9]}, {'screen_name': 'getify', 'name': 'getify', 'id': 16686076, 'id_str': '16686076', 'indices': [10, 17]}], 'symbols': []}}
正如你所看到的,这比文本要详细得多
我目前正在使用Python,并试图用正则表达式来概括我的想法。我可以轻松地从索引[I]到索引[j]对字符串进行切片,但由于所有tweet的长度不同,我需要确保从tweet开始的那一点开始对tweet进行切片,即“全文”:&&;'显示\u文本\u范围'
我并不是要求别人帮我做作业,但我已经在这个问题上纠结了一段时间,我最初认为简单的事情结果比我想象的要困难得多
有没有人能给我一些建议或建议,让我自己解决这个问题
谢谢
为什么不解析JSON以获取
full_text
属性相关问题 更多 >
编程相关推荐