Skip to content

Clean up filtered_stream.py #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Filtered-Stream/filtered_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import json

# To set your enviornment variables in your terminal run the following line:
# To set your environment variables in your terminal run the following line:
# export 'BEARER_TOKEN'='<your_bearer_token>'
bearer_token = os.environ.get("BEARER_TOKEN")

Expand Down Expand Up @@ -49,7 +49,7 @@ def delete_all_rules(rules):
print(json.dumps(response.json()))


def set_rules(delete):
def set_rules():
# You can adjust the rules if needed
sample_rules = [
{"value": "dog has:images", "tag": "dog pictures"},
Expand All @@ -68,7 +68,7 @@ def set_rules(delete):
print(json.dumps(response.json()))


def get_stream(set):
def get_stream():
response = requests.get(
"https://api.twitter.com/2/tweets/search/stream", auth=bearer_oauth, stream=True,
)
Expand All @@ -87,9 +87,9 @@ def get_stream(set):

def main():
rules = get_rules()
delete = delete_all_rules(rules)
set = set_rules(delete)
get_stream(set)
delete_all_rules(rules)
set_rules()
get_stream()


if __name__ == "__main__":
Expand Down