updated code and ran tests

This commit is contained in:
simplypower-bbj
2023-01-09 18:51:53 +01:00
parent 4cd14cd6a2
commit ec60648ad9
2 changed files with 40 additions and 18 deletions
+12 -6
View File
@@ -26,15 +26,21 @@
"source": [
"import snscrape.modules.twitter as sntwitter\n",
"import pandas as pd\n",
"tweet_list = list()\n",
"\n",
"# prepare variables\n",
"query = '(Odense OR odense OR #odense OR #Odense) until:2022-12-17 since:2017-01-01 -filter:replies'\n",
"limit = 1000\n",
"\n",
"tweet_list = list()\n",
"query = '(Odense OR odense OR #odense OR #Odense) until:2022-12-17 since:2017-01-01 -filter:replies'\n",
"# begin scraping\n",
"for i, tweet in enumerate(sntwitter.TwitterSearchScraper(query).get_items()):\n",
" if i % 100 == 0: print(f'found {i} tweets')\n",
" if i > limit: break\n",
" # if limit is reached, break out of loop\n",
" if limit > 0 and i > limit: break\n",
" # if another 100 tweets found, tell it\n",
" if i % 100 == 0: \n",
" print(f'found {i} tweets')\n",
" tweet_list.append([tweet.date, tweet.id, tweet.content, tweet.user.username])\n",
"\n",
"# create dataframe\n",
"df = pd.DataFrame(tweet_list, columns=['Datetime', 'Id', 'Text', 'Username'])"
]
},
@@ -216,7 +222,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.10.6 (main, Aug 11 2022, 13:49:25) [Clang 13.1.6 (clang-1316.0.21.2.5)]"
},
"orig_nbformat": 4,
"vscode": {