1
嗨銳推我使用Beautifulsoup刮Twitter的數據的數量,我想刮銳推每個鳴叫的次數和我下面的是我的代碼刮使用Beautifulsoup
import urllib2
from bs4 import BeautifulSoup
url = "https://twitter.com/nokia"
response = urllib2.urlopen(url)
soup = BeautifulSoup(response,"html.parser")
tweets = soup.findAll('li',{"class":'js-stream-item'})
for tweet in tweets:
if tweet.find('p',{"class":'tweet-text'}):
tweet_user = tweet.find('span',{"class":'username'}).text
tweet_text = tweet.find('p',{"class":'tweet-text'}).text.encode('utf8')
retweets = tweet.find('span',{"class":"ProfileTweet-actionCount"}).text
print(tweet_user)
print(tweet_text)
print(retweets)
else:
continue
我能夠得到tweet_user和tweet_text但銳推的一些如何沒能獲得數可有人解釋我如何雖然使用tweepy鼓勵
你很少的修改代碼得到銳推
不是答案,但使用Twitter API可以更容易實現! – leo
是的,我知道,但api有一個速度限制,而且你可以在 – srk
之前不超過7天得到推文。據我所知,無論多大年紀,你都可以得到3 200條推文。至少幾個星期前,我上次試過! – leo