forked from jupyter-naas/awesome-notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jravenel
committed
Jan 26, 2021
1 parent
ae66799
commit 5759c80
Showing
13 changed files
with
2,561 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"<img width=\"10%\" alt=\"Naas\" src=\"https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160\"/>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Canny posts create" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"<img width=\"20%\" alt=\"Naas\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAX8AAACECAMAAABPuNs7AAAAkFBMVEX///9fXflbWfmvrvxdW/mLivtWVPlZV/lUUvlXVfn6+v/9/f/Pzv1gXvmfnvtSUPlqaPnl5f6Bf/rV1f3Dwvy6uv1vbfqrqvyFhPp8e/r39/9kYvmbmvu3tvyBgPpnZfnu7v7k5P6jovuSkft0cvrf3v7Z2f3z8/+NjPrPz/3Hx/13dvqtrPxOS/lycPrJyf3IBu8AAAAQd0lEQVR4nO1d2WKiMBStMZIEl4AbrhX3Vqv+/9+NQBJW8cIgaOt5Gkeg5iTcPTcfH/ehb1t9a93IjFm9/70EPP+N29gO1tMTpxpD2UGYRvlp2OnbVY/iRWH+DLlGcO2/gAnl48G+6rG8HCaDLmf/yb0Eouyr1ax6RK+EycCgqBjyXWDCx62qB/UyaPYNWtDS94Fot1f1wF4Dl03x7HszMHrb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7lzwJ4E5WE9PTt9wlAOEUX4yZv3fv8HlodC3rb61bmTGulO/LN8aNxX/AHWDKokPsUNPAAAAAElFTkSuQmCC\"/>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Enter credentials" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import requests\n", | ||
"import json\n", | ||
"import pandas as pd" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"canny_api = \"**********\" # api key of canny\n", | ||
"post_title = \"Post title\" # Enter post title \n", | ||
"post_body = \"Post body using canny api\" # Enter post body" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Board dataframe using api-key" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"api_key = {\n", | ||
"\"apiKey\":canny_api \n", | ||
"}\n", | ||
"limit = {\n", | ||
"\"limit\":\"100\" \n", | ||
"}\n", | ||
"response = requests.get(\"https://canny.io/api/v1/boards/list\")\n", | ||
"response = requests.post(\"https://canny.io/api/v1/boards/list\", api_key)\n", | ||
"post_details = response.json()\n", | ||
"db = post_details['boards']\n", | ||
"df = pd.DataFrame(columns = db[0].keys()) \n", | ||
"for i in range(len(db)):\n", | ||
" df = df.append(db[i], ignore_index=True)\n", | ||
"df = df[['name','id']]\n", | ||
"board_list = df.rename(columns={'name': 'BOARD_NAME', 'id': 'BOARD_ID'})\n", | ||
"board_list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Enter board name" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"board_name = \"Requests\" #Enter board name\n", | ||
"for i in range(len(board_list)):\n", | ||
" if board_list['BOARD_NAME'][i] == board_name:\n", | ||
" board_id = board_list['BOARD_ID'][i]\n", | ||
"board_id\n", | ||
"board_id = {\n", | ||
"\"boardID\":board_id \n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Using api and board name to get author list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"response = requests.get(\"https://canny.io/api/v1/posts/list\")\n", | ||
"data = {**api_key, **board_id, **limit}\n", | ||
"response = requests.post(\"https://canny.io/api/v1/posts/list\", data)\n", | ||
"post_details = response.json()\n", | ||
"# post_details['posts']\n", | ||
"author_list = pd.DataFrame()\n", | ||
"for i in range(len(post_details['posts'])):\n", | ||
" author_list = author_list.append(post_details['posts'][i]['author'], ignore_index=True)\n", | ||
"author_list.drop_duplicates(subset =\"email\", keep = False, inplace = True)\n", | ||
"author_list = author_list[['name','id']]\n", | ||
"author_list = author_list.rename(columns={'name': 'AUTHOR_NAME', 'id': 'AUTHOR_ID'})\n", | ||
"author_list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Enter author name" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"author_name = \"Sanjay Sabu\" #Enter author name\n", | ||
"for i in author_list['AUTHOR_NAME'].index:\n", | ||
" if author_list['AUTHOR_NAME'][i] == author_name:\n", | ||
" author_id = author_list['AUTHOR_ID'][i]\n", | ||
"author_id = {\n", | ||
"\"authorID\":author_id \n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Creating post" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"post_title = {\n", | ||
"\"title\":post_title \n", | ||
"}\n", | ||
"post_body = {\n", | ||
"\"details\":post_body \n", | ||
"}\n", | ||
"data = {**api_key, **author_id, **board_id, **post_body, **post_title}\n", | ||
"response = requests.post(\"https://canny.io/api/v1/posts/create\", data)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.8.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.