|
9 | 9 | },
|
10 | 10 | {
|
11 | 11 | "cell_type": "code",
|
12 |
| - "execution_count": 6, |
| 12 | + "execution_count": 9, |
13 | 13 | "metadata": {},
|
14 | 14 | "outputs": [],
|
15 | 15 | "source": [
|
16 | 16 | "# A tutorial for this file is available at www.relataly.com\n",
|
17 |
| - "# Tested with Python 3.9.13, 1.2.0, Pandas 1.3.4, OpenAI 0.27.3, Tweepy 4.13.0, Requests 2.26.0, Azure.identity 1.7.0, azure.keyvault.secrets 4.6.0\n", |
| 17 | + "# Tested with Python 3.9.13, 1.2.0, Pandas 1.3.4, OpenAI 0.27.3, Tweepy 4.13.0, Requests 2.26.0, \n", |
18 | 18 | "\n",
|
19 | 19 | "import logging\n",
|
20 | 20 | "import pandas as pd\n",
|
21 | 21 | "import openai\n",
|
22 | 22 | "import tweepy\n",
|
23 | 23 | "import csv\n",
|
24 | 24 | "import requests\n",
|
25 |
| - "from azure.keyvault.secrets import SecretClient\n", |
26 |
| - "from azure.identity import AzureCliCredential\n", |
27 | 25 | "\n",
|
28 | 26 | "# Set API Keys and Authentification\n",
|
29 |
| - "logging.info('Setting Key Vault Auth')\n", |
30 |
| - "client = SecretClient(f\"https://{'keyvaultforbot'}.vault.azure.net/\", AzureCliCredential())\n", |
31 |
| - "\n", |
32 | 27 | "logging.info('Setting NewsAPI API Key')\n",
|
33 |
| - "NEWSAPI_API_KEY = client.get_secret('newsapi-api-key').value\n", |
| 28 | + "NEWSAPI_API_KEY = <your API key> # replace with own API key\n", |
34 | 29 | "\n",
|
35 | 30 | "logging.info('Setting OpenAI API Key')\n",
|
36 |
| - "OPENAI_API_KEY = client.get_secret('openai-api-key').value\n", |
37 |
| - "openai.api_key = OPENAI_API_KEY\n", |
| 31 | + "openai.api_key = <your API key> # replace with own API key\n", |
38 | 32 | "\n",
|
39 | 33 | "logging.info('Setting Twitter API Key')\n",
|
40 |
| - "auth=tweepy.OAuthHandler(client.get_secret('twitter-api-key').value,\n", |
41 |
| - " client.get_secret('twitter-api-secret').value)\n", |
42 |
| - "auth.set_access_token(client.get_secret('twitter-access-token').value,\n", |
43 |
| - " client.get_secret('twitter-access-secret').value)\n", |
| 34 | + "auth=tweepy.OAuthHandler(<your API key>,\n", |
| 35 | + " <your API secret>)\n", |
| 36 | + "auth.set_access_token(<your access token>,\n", |
| 37 | + " <your access secret>)\n", |
44 | 38 | "twitter_api=tweepy.API(auth)\n",
|
45 | 39 | "\n",
|
46 | 40 | "CSV_NAME = 'news_log.csv'"
|
|
55 | 49 | },
|
56 | 50 | {
|
57 | 51 | "cell_type": "code",
|
58 |
| - "execution_count": 7, |
| 52 | + "execution_count": 10, |
59 | 53 | "metadata": {},
|
60 | 54 | "outputs": [],
|
61 | 55 | "source": [
|
|
79 | 73 | },
|
80 | 74 | {
|
81 | 75 | "cell_type": "code",
|
82 |
| - "execution_count": 8, |
| 76 | + "execution_count": 11, |
83 | 77 | "metadata": {},
|
84 | 78 | "outputs": [],
|
85 | 79 | "source": [
|
|
127 | 121 | },
|
128 | 122 | {
|
129 | 123 | "cell_type": "code",
|
130 |
| - "execution_count": 9, |
| 124 | + "execution_count": 12, |
131 | 125 | "metadata": {},
|
132 | 126 | "outputs": [],
|
133 | 127 | "source": [
|
|
174 | 168 | },
|
175 | 169 | {
|
176 | 170 | "cell_type": "code",
|
177 |
| - "execution_count": 10, |
| 171 | + "execution_count": 13, |
178 | 172 | "metadata": {},
|
179 | 173 | "outputs": [
|
180 | 174 | {
|
|
207 | 201 | " <tbody>\n",
|
208 | 202 | " <tr>\n",
|
209 | 203 | " <th>0</th>\n",
|
210 |
| - " <td>6 Things Horizon 3 Needs to Succeed - Beyond C...</td>\n", |
211 |
| - " <td>In this clip of Podcast Beyond, Jada Griffin, ...</td>\n", |
212 |
| - " <td>https://www.youtube.com/watch?v=2eHTGrobyEg</td>\n", |
| 204 | + " <td>The iPhone 14 Pro is a demonstration of what o...</td>\n", |
| 205 | + " <td>Apple’s iPhone 14 Pro is getting more useful w...</td>\n", |
| 206 | + " <td>https://www.theverge.com/2023/5/5/23711698/iph...</td>\n", |
213 | 207 | " <td>False</td>\n",
|
214 | 208 | " </tr>\n",
|
215 | 209 | " <tr>\n",
|
216 | 210 | " <th>1</th>\n",
|
217 |
| - " <td>MMORPG Chrono Odyssey 'Gameplay Reveal' traile...</td>\n", |
218 |
| - " <td>South Korea-based game developer NPIXEL has re...</td>\n", |
219 |
| - " <td>https://www.gematsu.com/2023/05/mmorpg-chrono-...</td>\n", |
| 211 | + " <td>Huge update is launched for billions of Gmail ...</td>\n", |
| 212 | + " <td>Google has unveiled a huge update that signals...</td>\n", |
| 213 | + " <td>https://www.dailymail.co.uk/sciencetech/articl...</td>\n", |
220 | 214 | " <td>False</td>\n",
|
221 | 215 | " </tr>\n",
|
222 | 216 | " <tr>\n",
|
223 | 217 | " <th>2</th>\n",
|
224 |
| - " <td>Google is replacing Chrome’s misleading lock i...</td>\n", |
225 |
| - " <td>Google announced that the lock will be replace...</td>\n", |
226 |
| - " <td>https://www.theverge.com/2023/5/3/23709498/goo...</td>\n", |
| 218 | + " <td>JBL Tour Pro 2 review: Welcome to the smart ca...</td>\n", |
| 219 | + " <td>JBL threw a ton of features in the Tour Pro 2 ...</td>\n", |
| 220 | + " <td>https://www.engadget.com/jbl-tour-pro-2-review...</td>\n", |
227 | 221 | " <td>False</td>\n",
|
228 | 222 | " </tr>\n",
|
229 | 223 | " <tr>\n",
|
230 | 224 | " <th>3</th>\n",
|
231 |
| - " <td>The new Pokémon Trading Card Game app is final...</td>\n", |
232 |
| - " <td>Pokémon Trading Card Game Live will launch on ...</td>\n", |
233 |
| - " <td>https://www.theverge.com/2023/5/3/23709584/pok...</td>\n", |
| 225 | + " <td>Tech Issues Are Plaguing Next-Gen Games - Next...</td>\n", |
| 226 | + " <td>In this week's monster-sized episode of Next-G...</td>\n", |
| 227 | + " <td>https://www.youtube.com/watch?v=WqF9V1dwBW0</td>\n", |
234 | 228 | " <td>False</td>\n",
|
235 | 229 | " </tr>\n",
|
236 | 230 | " <tr>\n",
|
237 | 231 | " <th>4</th>\n",
|
238 |
| - " <td>Apple and Google are teaming up on a plan to m...</td>\n", |
239 |
| - " <td>Apple and Google are working together on a new...</td>\n", |
240 |
| - " <td>https://www.cnn.com/2023/05/03/tech/airtags-ap...</td>\n", |
| 232 | + " <td>Xbox boss raises eyebrows with claim Microsoft...</td>\n", |
| 233 | + " <td>As the fallout from Redfall's release continue...</td>\n", |
| 234 | + " <td>https://www.eurogamer.net/xbox-boss-raises-eye...</td>\n", |
241 | 235 | " <td>False</td>\n",
|
242 | 236 | " </tr>\n",
|
243 | 237 | " <tr>\n",
|
244 | 238 | " <th>5</th>\n",
|
245 |
| - " <td>Researchers See Through a Mouse's Eyes by Deco...</td>\n", |
246 |
| - " <td>Don't worry, the technology can't be used to r...</td>\n", |
247 |
| - " <td>https://gizmodo.com/ai-deep-learning-brain-act...</td>\n", |
248 |
| - " <td>True</td>\n", |
| 239 | + " <td>May 2023 update lands on Galaxy S22, starting ...</td>\n", |
| 240 | + " <td>Samsung is one week into the May 2023 security...</td>\n", |
| 241 | + " <td>https://www.sammobile.com/news/may-2023-update...</td>\n", |
| 242 | + " <td>False</td>\n", |
249 | 243 | " </tr>\n",
|
250 | 244 | " <tr>\n",
|
251 | 245 | " <th>6</th>\n",
|
252 |
| - " <td>F1 23 release date announced with Braking Poin...</td>\n", |
253 |
| - " <td>F1 2023 launches June 16, 2023 for PlayStation...</td>\n", |
254 |
| - " <td>https://www.polygon.com/23709519/f1-23-game-re...</td>\n", |
| 246 | + " <td>What to expect at Google I/O 2023 - Engadget</td>\n", |
| 247 | + " <td>Google is set to introduce Android 14 and new ...</td>\n", |
| 248 | + " <td>https://www.engadget.com/what-to-expect-at-goo...</td>\n", |
255 | 249 | " <td>False</td>\n",
|
256 | 250 | " </tr>\n",
|
257 | 251 | " <tr>\n",
|
258 | 252 | " <th>7</th>\n",
|
259 |
| - " <td>iOS 17 Coming Soon for iPhones and Rumored to ...</td>\n", |
260 |
| - " <td>Apple is expected to announce iOS 17 during it...</td>\n", |
261 |
| - " <td>https://www.macrumors.com/2023/05/03/ios-17-ru...</td>\n", |
| 253 | + " <td>PSA: you've got just one weekend left to claim...</td>\n", |
| 254 | + " <td>You’ve got until May 9th to claim the dozen-pl...</td>\n", |
| 255 | + " <td>https://www.theverge.com/2023/5/5/23712262/son...</td>\n", |
262 | 256 | " <td>False</td>\n",
|
263 | 257 | " </tr>\n",
|
264 | 258 | " <tr>\n",
|
265 | 259 | " <th>8</th>\n",
|
266 |
| - " <td>Pokémon GO's Monthly Earnings Have Fallen To A...</td>\n", |
267 |
| - " <td>Only $34.7 million, the horror</td>\n", |
268 |
| - " <td>https://www.nintendolife.com/news/2023/05/poke...</td>\n", |
| 260 | + " <td>How to Lock Specific iPhone Apps Behind Face I...</td>\n", |
| 261 | + " <td>In the interests of enhanced privacy, some thi...</td>\n", |
| 262 | + " <td>https://www.macrumors.com/how-to/automatically...</td>\n", |
269 | 263 | " <td>False</td>\n",
|
270 | 264 | " </tr>\n",
|
271 | 265 | " <tr>\n",
|
272 | 266 | " <th>9</th>\n",
|
273 |
| - " <td>Double Dragon Gaiden: Rise of the Dragons - Of...</td>\n", |
274 |
| - " <td>Watch the announcement trailer for Double Drag...</td>\n", |
275 |
| - " <td>https://www.youtube.com/watch?v=MksA6p7rqOM</td>\n", |
276 |
| - " <td>False</td>\n", |
| 267 | + " <td>Microsoft is allegedly working with AMD to exp...</td>\n", |
| 268 | + " <td>Microsoft is allegedly providing engineering r...</td>\n", |
| 269 | + " <td>https://www.theverge.com/2023/5/5/23712242/mic...</td>\n", |
| 270 | + " <td>True</td>\n", |
277 | 271 | " </tr>\n",
|
278 | 272 | " </tbody>\n",
|
279 | 273 | "</table>\n",
|
280 | 274 | "</div>"
|
281 | 275 | ],
|
282 | 276 | "text/plain": [
|
283 | 277 | " title \\\n",
|
284 |
| - "0 6 Things Horizon 3 Needs to Succeed - Beyond C... \n", |
285 |
| - "1 MMORPG Chrono Odyssey 'Gameplay Reveal' traile... \n", |
286 |
| - "2 Google is replacing Chrome’s misleading lock i... \n", |
287 |
| - "3 The new Pokémon Trading Card Game app is final... \n", |
288 |
| - "4 Apple and Google are teaming up on a plan to m... \n", |
289 |
| - "5 Researchers See Through a Mouse's Eyes by Deco... \n", |
290 |
| - "6 F1 23 release date announced with Braking Poin... \n", |
291 |
| - "7 iOS 17 Coming Soon for iPhones and Rumored to ... \n", |
292 |
| - "8 Pokémon GO's Monthly Earnings Have Fallen To A... \n", |
293 |
| - "9 Double Dragon Gaiden: Rise of the Dragons - Of... \n", |
| 278 | + "0 The iPhone 14 Pro is a demonstration of what o... \n", |
| 279 | + "1 Huge update is launched for billions of Gmail ... \n", |
| 280 | + "2 JBL Tour Pro 2 review: Welcome to the smart ca... \n", |
| 281 | + "3 Tech Issues Are Plaguing Next-Gen Games - Next... \n", |
| 282 | + "4 Xbox boss raises eyebrows with claim Microsoft... \n", |
| 283 | + "5 May 2023 update lands on Galaxy S22, starting ... \n", |
| 284 | + "6 What to expect at Google I/O 2023 - Engadget \n", |
| 285 | + "7 PSA: you've got just one weekend left to claim... \n", |
| 286 | + "8 How to Lock Specific iPhone Apps Behind Face I... \n", |
| 287 | + "9 Microsoft is allegedly working with AMD to exp... \n", |
294 | 288 | "\n",
|
295 | 289 | " description \\\n",
|
296 |
| - "0 In this clip of Podcast Beyond, Jada Griffin, ... \n", |
297 |
| - "1 South Korea-based game developer NPIXEL has re... \n", |
298 |
| - "2 Google announced that the lock will be replace... \n", |
299 |
| - "3 Pokémon Trading Card Game Live will launch on ... \n", |
300 |
| - "4 Apple and Google are working together on a new... \n", |
301 |
| - "5 Don't worry, the technology can't be used to r... \n", |
302 |
| - "6 F1 2023 launches June 16, 2023 for PlayStation... \n", |
303 |
| - "7 Apple is expected to announce iOS 17 during it... \n", |
304 |
| - "8 Only $34.7 million, the horror \n", |
305 |
| - "9 Watch the announcement trailer for Double Drag... \n", |
| 290 | + "0 Apple’s iPhone 14 Pro is getting more useful w... \n", |
| 291 | + "1 Google has unveiled a huge update that signals... \n", |
| 292 | + "2 JBL threw a ton of features in the Tour Pro 2 ... \n", |
| 293 | + "3 In this week's monster-sized episode of Next-G... \n", |
| 294 | + "4 As the fallout from Redfall's release continue... \n", |
| 295 | + "5 Samsung is one week into the May 2023 security... \n", |
| 296 | + "6 Google is set to introduce Android 14 and new ... \n", |
| 297 | + "7 You’ve got until May 9th to claim the dozen-pl... \n", |
| 298 | + "8 In the interests of enhanced privacy, some thi... \n", |
| 299 | + "9 Microsoft is allegedly providing engineering r... \n", |
306 | 300 | "\n",
|
307 | 301 | " url relevance \n",
|
308 |
| - "0 https://www.youtube.com/watch?v=2eHTGrobyEg False \n", |
309 |
| - "1 https://www.gematsu.com/2023/05/mmorpg-chrono-... False \n", |
310 |
| - "2 https://www.theverge.com/2023/5/3/23709498/goo... False \n", |
311 |
| - "3 https://www.theverge.com/2023/5/3/23709584/pok... False \n", |
312 |
| - "4 https://www.cnn.com/2023/05/03/tech/airtags-ap... False \n", |
313 |
| - "5 https://gizmodo.com/ai-deep-learning-brain-act... True \n", |
314 |
| - "6 https://www.polygon.com/23709519/f1-23-game-re... False \n", |
315 |
| - "7 https://www.macrumors.com/2023/05/03/ios-17-ru... False \n", |
316 |
| - "8 https://www.nintendolife.com/news/2023/05/poke... False \n", |
317 |
| - "9 https://www.youtube.com/watch?v=MksA6p7rqOM False " |
| 302 | + "0 https://www.theverge.com/2023/5/5/23711698/iph... False \n", |
| 303 | + "1 https://www.dailymail.co.uk/sciencetech/articl... False \n", |
| 304 | + "2 https://www.engadget.com/jbl-tour-pro-2-review... False \n", |
| 305 | + "3 https://www.youtube.com/watch?v=WqF9V1dwBW0 False \n", |
| 306 | + "4 https://www.eurogamer.net/xbox-boss-raises-eye... False \n", |
| 307 | + "5 https://www.sammobile.com/news/may-2023-update... False \n", |
| 308 | + "6 https://www.engadget.com/what-to-expect-at-goo... False \n", |
| 309 | + "7 https://www.theverge.com/2023/5/5/23712262/son... False \n", |
| 310 | + "8 https://www.macrumors.com/how-to/automatically... False \n", |
| 311 | + "9 https://www.theverge.com/2023/5/5/23712242/mic... True " |
318 | 312 | ]
|
319 | 313 | },
|
320 | 314 | "metadata": {},
|
|
324 | 318 | "name": "stdout",
|
325 | 319 | "output_type": "stream",
|
326 | 320 | "text": [
|
327 |
| - "Already tweeted: Researchers See Through a Mouse's Eyes by Decoding Brain Signals - Gizmodo\n" |
| 321 | + "Tweet too long: 335\n", |
| 322 | + "error tweet too long\n", |
| 323 | + "Tweeted: Microsoft is allegedly working with AMD to expand into AI chips - The Verge\n" |
328 | 324 | ]
|
329 | 325 | }
|
330 | 326 | ],
|
|
380 | 376 | "\n",
|
381 | 377 | "main_bot()"
|
382 | 378 | ]
|
| 379 | + }, |
| 380 | + { |
| 381 | + "cell_type": "code", |
| 382 | + "execution_count": 14, |
| 383 | + "metadata": {}, |
| 384 | + "outputs": [ |
| 385 | + { |
| 386 | + "data": { |
| 387 | + "text/html": [ |
| 388 | + "<div>\n", |
| 389 | + "<style scoped>\n", |
| 390 | + " .dataframe tbody tr th:only-of-type {\n", |
| 391 | + " vertical-align: middle;\n", |
| 392 | + " }\n", |
| 393 | + "\n", |
| 394 | + " .dataframe tbody tr th {\n", |
| 395 | + " vertical-align: top;\n", |
| 396 | + " }\n", |
| 397 | + "\n", |
| 398 | + " .dataframe thead th {\n", |
| 399 | + " text-align: right;\n", |
| 400 | + " }\n", |
| 401 | + "</style>\n", |
| 402 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 403 | + " <thead>\n", |
| 404 | + " <tr style=\"text-align: right;\">\n", |
| 405 | + " <th></th>\n", |
| 406 | + " <th>title</th>\n", |
| 407 | + " </tr>\n", |
| 408 | + " </thead>\n", |
| 409 | + " <tbody>\n", |
| 410 | + " <tr>\n", |
| 411 | + " <th>0</th>\n", |
| 412 | + " <td>Researchers See Through a Mouse's Eyes by Deco...</td>\n", |
| 413 | + " </tr>\n", |
| 414 | + " <tr>\n", |
| 415 | + " <th>1</th>\n", |
| 416 | + " <td>Google DeepMind CEO says human-level AI will b...</td>\n", |
| 417 | + " </tr>\n", |
| 418 | + " <tr>\n", |
| 419 | + " <th>2</th>\n", |
| 420 | + " <td>AMD jumps 9% on report Microsoft is collaborat...</td>\n", |
| 421 | + " </tr>\n", |
| 422 | + " <tr>\n", |
| 423 | + " <th>3</th>\n", |
| 424 | + " <td>Next week's Google I/O event may change Samsun...</td>\n", |
| 425 | + " </tr>\n", |
| 426 | + " <tr>\n", |
| 427 | + " <th>4</th>\n", |
| 428 | + " <td>Microsoft barrels ahead with AI plans, opens u...</td>\n", |
| 429 | + " </tr>\n", |
| 430 | + " <tr>\n", |
| 431 | + " <th>5</th>\n", |
| 432 | + " <td>'Godfather of artificial intelligence' says AI...</td>\n", |
| 433 | + " </tr>\n", |
| 434 | + " <tr>\n", |
| 435 | + " <th>6</th>\n", |
| 436 | + " <td>Microsoft is allegedly working with AMD to exp...</td>\n", |
| 437 | + " </tr>\n", |
| 438 | + " <tr>\n", |
| 439 | + " <th>7</th>\n", |
| 440 | + " <td>katze</td>\n", |
| 441 | + " </tr>\n", |
| 442 | + " </tbody>\n", |
| 443 | + "</table>\n", |
| 444 | + "</div>" |
| 445 | + ], |
| 446 | + "text/plain": [ |
| 447 | + " title\n", |
| 448 | + "0 Researchers See Through a Mouse's Eyes by Deco...\n", |
| 449 | + "1 Google DeepMind CEO says human-level AI will b...\n", |
| 450 | + "2 AMD jumps 9% on report Microsoft is collaborat...\n", |
| 451 | + "3 Next week's Google I/O event may change Samsun...\n", |
| 452 | + "4 Microsoft barrels ahead with AI plans, opens u...\n", |
| 453 | + "5 'Godfather of artificial intelligence' says AI...\n", |
| 454 | + "6 Microsoft is allegedly working with AMD to exp...\n", |
| 455 | + "7 katze" |
| 456 | + ] |
| 457 | + }, |
| 458 | + "execution_count": 14, |
| 459 | + "metadata": {}, |
| 460 | + "output_type": "execute_result" |
| 461 | + } |
| 462 | + ], |
| 463 | + "source": [ |
| 464 | + "\n", |
| 465 | + "CSV_NAME = 'news_log.csv'\n", |
| 466 | + "df_old = pd.read_csv(CSV_NAME)\n", |
| 467 | + "import pandas as pd\n", |
| 468 | + "title = 'katze'\n", |
| 469 | + "df = pd.DataFrame({'title': [title]})\n", |
| 470 | + "df\n", |
| 471 | + "df_old = pd.concat([df_old, df], ignore_index=True)\n", |
| 472 | + "df_old" |
| 473 | + ] |
383 | 474 | }
|
384 | 475 | ],
|
385 | 476 | "metadata": {
|
|
0 commit comments