added example

This commit is contained in:
Trevor Hobenshield
2023-03-18 19:09:55 -07:00
parent c4cdfde5f8
commit 7c97fa01a5

77
examples/tweets.ipynb Normal file
View File

@@ -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
}