Search code examples
pythontweepy

How to search for keywords using strings in Python


Hi so I need a bit of help on creating strings that will scrape for tweets that include mentions of Yeezy + Footpatrol for example.

So it only picks up Yeezy if Footpatrol is mentioned.

I don't want to specifically write variable strings for example:

t = ['Hello world!',
    'Hello World!',
    'Hello World!!!',
    'Hello world!!!',
    'Hello, world!',
    'Hello, World!']

I only want to push retweets using a nested for loop when mentions of both footpatrol and Yeezy are in the same line of text.


Solution

  • Using in keyword:

    if 'footpatrol' in line and 'Yeezy' in line:
        # Do your stuff
        # Pass