2017-03-03 8 views
-1

カーソルの終了時刻を29日に変更すると、すべてが0になります。しかし、私が28日にそれを変更すると、私はすべての情報を得ます。 2月のPython 2.7 Twitter Scraper

start = "2017-02-25" 
    end = "2017-02-29" 
    for status in tweepy.Cursor(api.search, q=i,since=start,until=end,lang="en").items(): 

     parsed = status._json 
     usercount[parsed['user']['name'].encode("utf-8")]+=1 
     userfollowers[parsed['user']['name'].encode("utf-8")]= parsed['user']['followers_count'] 
     mostretweets[parsed['text'].encode('utf-8')] = parsed['retweet_count']   
     mostfav[parsed['text'].encode('utf-8')] = parsed['favorite_count'] 
+0

feb(2)には28日しかありません... 2017年でないうるう年でない限り、 – depperm

+0

何が具体的にお手伝いしますか? '2017-02-29'は有効な日付ではありません。 – thaavik

答えて

2

29日には、(少なくとも、2017年)が存在しない、それが有効な日付ではありません...

2

datetimeを使用することを求めて、そのすでに日付の検証があるでしょう。

 
from datetime import datetime 
datetime(2017, 2, 29) 

ValueError: day is out of range for month 

start = datetime(2017, 2, 25).strftime("%Y-%m-%d") 
end = datetime(2017, 2, 28).strftime("%Y-%m-%d")