0
因此,我試圖搜索推特包含特定的單詞在Twitter API(tweepy包裝)。但是,當搜索單詞時,我正在接近結果。 (即搜索「有」,但tweepy回報「有」有什麼辦法可以指定與tweepy,你想要的確切期限Twitter API(Tweepy)如何獲得確切的術語
我的代碼部分:
otherTweet = tweepy.Cursor(api.search, q=word and hashtag, count=1, lang="en").items(1) # searches for words needed to retweet later
for a in otherTweet:
ref = a.text.encode("unicode-escape")
if "#" in ref and word not in ref.split(" ") or not otherTweet:
otherTweet = tweepy.Cursor(api.search, q=word, count=1, lang="en").items(1) # Can't find tweet with right hashtag.
print "got here"
字和#標籤是這兩個變量,例如word =「hello」hashtag =「#blessed」我假設我爲他們做了一些事情來獲得特定的條款
我試過了,但它似乎沒有影響任何東西。仍然得到像「那裏!」的東西可能不得不嘗試第二種選擇。 –
我從不擔心標點符號,我認爲這是問題(嘰嘰喳喳單詞搜索API可能會將標點符號視爲搜索空白)。如果是這種情況,第二種選擇是最好的選擇,但實施太困難了。 '.split()'是你正在尋找的東西,應該只需要一個額外的邏輯塊來修復。 –
是的,你說得對,標點符號似乎沒有考慮。分裂是我最終必須做的事情。有點討厭,但總比沒有好。 –