feat: optionally scrape followers and following

This commit is contained in:
Jarrian
2023-09-25 08:27:08 +08:00
parent ed0be321bb
commit 069b0cc24a
4 changed files with 217 additions and 76 deletions

View File

@@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": 113,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -57,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 114,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -97,7 +97,7 @@
},
{
"cell_type": "code",
"execution_count": 115,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -141,7 +141,7 @@
},
{
"cell_type": "code",
"execution_count": 116,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -387,13 +387,12 @@
},
{
"cell_type": "code",
"execution_count": 117,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"TWITTER_LOGIN_URL = \"https://twitter.com/i/flow/login\"\n",
"\n",
"\n",
"class Twitter_Scraper:\n",
" def __init__(\n",
" self,\n",
@@ -410,6 +409,7 @@
" print(\"Initializing Twitter Scraper...\")\n",
" self.username = username\n",
" self.password = password\n",
" self.interrupted = False\n",
" self.tweet_ids = set()\n",
" self.data = []\n",
" self.tweet_cards = []\n",
@@ -829,6 +829,7 @@
" except KeyboardInterrupt:\n",
" print(\"\\n\")\n",
" print(\"Keyboard Interrupt\")\n",
" self.interrupted = True\n",
" break\n",
" except Exception as e:\n",
" print(\"\\n\")\n",
@@ -899,7 +900,7 @@
},
{
"cell_type": "code",
"execution_count": 118,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -932,7 +933,7 @@
},
{
"cell_type": "code",
"execution_count": 119,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -961,7 +962,7 @@
},
{
"cell_type": "code",
"execution_count": 120,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -998,7 +999,7 @@
},
{
"cell_type": "code",
"execution_count": 121,
"execution_count": 9,
"metadata": {},
"outputs": [
{
@@ -1006,7 +1007,7 @@
"output_type": "stream",
"text": [
"Saving Tweets to CSV...\n",
"CSV Saved: ./tweets/2023-09-24_23-57-11_tweets_1-50.csv\n"
"CSV Saved: ./tweets/2023-09-25_08-20-51_tweets_1-50.csv\n"
]
}
],
@@ -1016,7 +1017,7 @@
},
{
"cell_type": "code",
"execution_count": 122,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [