Python 3.x Python twint库在Colab环境中不工作

Python 3.x Python twint库在Colab环境中不工作,python-3.x,web-scraping,google-colaboratory,twint,Python 3.x,Web Scraping,Google Colaboratory,Twint,我试图在Colab中使用Python的twint库(Twitter scraper)运行代码 我的代码是: !pip install twint !pip install nest_asyncio !pip install pandas import twint import nest_asyncio nest_asyncio.apply() import time import pandas as pd import os import re timestr = time.strftime

我试图在Colab中使用Python的twint库(Twitter scraper)运行代码

我的代码是:

!pip install twint
!pip install nest_asyncio
!pip install pandas

import twint
import nest_asyncio
nest_asyncio.apply()
import time
import pandas as pd
import os
import re

timestr = time.strftime("%Y%m%d")

c = twint.Config()
c.Limit = 1000
c.Lang = "en"
c.Store_csv = True
c.Search = "apple"
c.Output = timestr + "_en_apple.csv"
twint.run.Search(c)
上面的代码在我的机器上的Jupyter中完美地工作,并获取tweet。但是,Colab中的相同代码会产生以下结果:

 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 1.0 secs
 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 8.0 secs
 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 27.0 secs
 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 64.0 secs
 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 125.0 secs
 CRITICAL:root:twint.run:Twint:Feed:noDataExpecting value: line 1 column 1 (char 0)
 sleeping for 216.0 secs

如何在Colab中修复此问题?

我在Google Colab中获得了以下内容。从requirements.txt安装不那么麻烦

!git clone --depth=1 https://github.com/twintproject/twint.git
!cd /content/twint && pip3 install . -r requirements.txt
import twint
import nest_asyncio
nest_asyncio.apply()
import time
import pandas as pd
import os
import re
timestr = time.strftime("%Y%m%d")

c = twint.Config()
c.Limit = 1000
c.Lang = "en"
c.Store_csv = True
c.Search = "apple"
c.Output = timestr + "_en_apple.csv"
twint.run.Search(c)

我在Google Colab工作时得到了以下信息。从requirements.txt安装不那么麻烦

!git clone --depth=1 https://github.com/twintproject/twint.git
!cd /content/twint && pip3 install . -r requirements.txt
import twint
import nest_asyncio
nest_asyncio.apply()
import time
import pandas as pd
import os
import re
timestr = time.strftime("%Y%m%d")

c = twint.Config()
c.Limit = 1000
c.Lang = "en"
c.Store_csv = True
c.Search = "apple"
c.Output = timestr + "_en_apple.csv"
twint.run.Search(c)

我试过了,它给了我一个错误:AttributeError:module'twint'没有属性'Config'。你创建了一个全新的Colab笔记本并将代码粘贴到一个单元格中并运行了吗?这是我的一个Colab笔记本的链接。在把所有东西都放进一个牢房后,他成功了。我只是好奇,为什么它不能在不同的单元格中工作。它对我来说可以在多个单元格中工作。我尝试了它,但它给了我一个错误:AttributeError:module'twint'没有属性'Config'你是否创建了一个全新的Colab笔记本,并将代码粘贴到一个单元格中并运行它?这是我的一个Colab笔记本的链接。在把所有东西都放进一个牢房后,他成功了。我只是好奇,为什么它不能在不同的细胞中工作。它对我来说可以在多个细胞中工作。