asked    Edith     2018-10-22       python       84 view        1 Answer

[SOLVED] Tweepy Cursor Search - User input and Mention

I'm trying to have a user input search and a set search parameter in the api.search function of tweepy.

Essentially I want it like this:

print("input search term to search within Tesla tweets")
keyword = input()
print("Thanks!")
print("Tweets are cooking in the background now...")


# create list to append tweets to
tweets = []

# append all tweet data to list
for tweet in tweepy.Cursor(api.search, q="@tesla" + keyword, tweet_mode="extended", count=10000, 
                       since="2018-08-01").items():
    tweets.append(tweet)
    word_string = repr(tweet)

But that won't work it just doesn't return any tweets

So I've tried it like this, which works, but it returns anything with @tesla in the tweet, not tweets mentioning tesla, so it's not ideal-

print("input search term to search within Tesla tweets")
keyword = input() + "@Tesla"
print("Thanks!")
print("Tweets are cooking in the background now...")

tweets = []

for tweet in tweepy.Cursor(api.search, keyword, tweet_mode="extended", count=10000, 
                       since="2018-08-01").items():
    tweets.append(tweet)
    word_string = repr(tweet)

Is there any way I can do the first option or will I just have to live with it, it's not major, so it's not a big deal if so?

Thanks!

  1 Answer  

        answered    Denise     2018-10-22      

I found an easier solution to this problem, not sure how to close the question, but thought I'd put an answer for reference in case someone is having the same problem :)

Turns out you can't use boolean operators unless you have a premium twitter dev account.

So instead I just did the @tesla search, put it into the pandas dataframe, and then I filtered the pandas dataframe for the user input search term. Much easier to do, but limits my search terms is the only caveat.





Your Answer





 2018-10-22         Emmanuel

GTest: fixture required when TYPE_TESTING global functions?

I want to unit-test some global templated functions using TYPED_TEST. The following code works, I just wonder whether there is way I can get rid of the test fixture, as it does not seem to be needed..#include <gtest/gtest.h>#include <base/mathfunctions.h>template <class T>class MinTest : public testing::Test {};// The list of types we want to test.typedef ::testing::Types<int, float> Implementations;TYPED_TEST_CASE(MinTest, Implementations);TYPED_TEST(MinTest, ReturnsMinimumValue) { EXPECT_EQ(Base::Min<TypeParam>(-5, 5), -5);} ... as it ...
 unit-testing                     1 answers                     61 view
 2018-10-22         Chester

How do I inject build version into pom.xml using TFS on UI?

I have a TFS build definition that deals with a java spring backend application that is built with Maven. I have a build step called "Maven pom.xml" where I obviously can set some options of the pom.xml. I need to change the "version" tag in the pom.xml using TFS whilst building, so that the "info" endpoint in actuator serves the correct version number including the TFS build number.1) Is this possible using the TFS UI at all? 2) If yes, should I change "Options" textbox content or "MAVEN_OPTS" and how do I feed parameters there, that change <version> in the pom.xml? ...
 java                     2 answers                     63 view
 2018-10-22         Burnell

After logging in I am redirected to /robots.txt

So since a couple of weeks now we have noticed some strange behaviour on a couple of projects that use Spring Boot and Spring Security.Mostly only OSX users seem to have this issue but whenever we login to our application it randomly redirects back to robots.txtI realise that this is probably not enough info, but sadly it's all I got. We have seen this pop up only on OSX so far and on 3 different projects (some live and some running locally)server logs have this as request info (I removed/obfuscated some the real info):Request parameters:Request attributes:javax.servlet.for...
 spring-boot                     1 answers                     64 view