From 7c97fa01a55bed4b7d15cfec755ce6463a3ec852 Mon Sep 17 00:00:00 2001 From: Trevor Hobenshield Date: Sat, 18 Mar 2023 19:09:55 -0700 Subject: [PATCH] added example --- examples/tweets.ipynb | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 examples/tweets.ipynb diff --git a/examples/tweets.ipynb b/examples/tweets.ipynb new file mode 100644 index 0000000..b9722d7 --- /dev/null +++ b/examples/tweets.ipynb @@ -0,0 +1,77 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "f65b5a54", + "metadata": {}, + "outputs": [], + "source": [ + "from twitter import scraper\n", + "from twitter.login import login\n", + "from twitter.utils import find_key" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1d7714a8", + "metadata": {}, + "outputs": [], + "source": [ + "username,password = ...,...\n", + "s = login(username, password)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "50c68c90", + "metadata": {}, + "outputs": [], + "source": [ + "tweets = scraper.get_user_tweets(s, [123,234,345,456,567])" + ] + }, + { + "cell_type": "markdown", + "id": "a1339a2b", + "metadata": {}, + "source": [ + "#### Find all unique urls in users tweets" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f64a96d9", + "metadata": {}, + "outputs": [], + "source": [ + "unique_urls = set(find_key(tweets,'expanded_url'))\n", + "unique_urls" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}