Я извлек некоторую контактную информацию с веб-сайта, используя api
, и распечатал ее, используя python, но мне нужно было отправить данные в мою базу данных Oracle, где я уже создал таблицу.Будет очень полезно, если вы сможете сделать это, используя cx_oracle
.
Я хочу вывод в таблицу базы данных.
import requests
url = "https://********.api-us1.com/api/3/contacts?
include=fieldValues&limit=100&orders[cdate]=DESC"
httpHeader={'Api-Token''3d229bde5b7f8e03ada8d0ef5ac0be70bdf1693f3c781caf9255237*******c03a438da'}
response = requests.get(url,headers=httpHeader).json()
number_of_contacts_str = response['meta']['total']
number_of_contacts = int(number_of_contacts_str)
i=0
print()
print('{:^10}{:^20}{:^20}{:^14}{:^30}{:^20}{:^20}'.format('Sl.No','First Name','Last Name','Phone','Email','Course','Date'))
print()
while i<number_of_contacts:
date = response['contacts'][i]['cdate']
email = response['contacts'][i]['email']
phone = response['contacts'][i]['phone']
firstName = response['contacts'][i]['firstName']
lastName = response['contacts'][i]['lastName']
course = response['fieldValues'][i]['value']
date_response1 = response['fieldValues'][i]['cdate']
print('{:^10}{:<20}{:<20}{:<14}{:<30}{:<20}{:<20}'.format((i+1),firstName,lastName,phone,email,course,date))
#print(response)
#print(date)
i+=1
Вывод
Sl.No First Name Last Name Phone Email Course Date
1 NameTwentyThree Wayne 7867904678 nametwentythree@gmail.com Twenty three 2018-12-08T14:51:39-06:00
2 NameTwentyTwo Arigato 6578967543 nametwentytwo@gmail.com Twenty two 2018-12-08T14:50:09-06:00
3 NameTwentyOne Parker 7856748397 nametwentyone@gmail.com Twenty one 2018-12-08T14:48:56-06:00
4 NameTwenty Konichiwa 6748397289 nametwenty@gmail.com Twenty 2018-12-08T14:46:46-06:00
5 NameNinteen Lee 9867456738 nameninteen@gmail.com Ninteen 2018-12-08T14:45:50-06:00
6 NameEighteen Shroff 8695047837 nameeighteen@gmail.com Eighteen 2018-12-08T14:44:41-06:00
7 NameSeventeen Kapoor 8746983767 nameseventeen@gmail.com Seventeen 2018-12-08T14:43:46-06:00
8 NameSixteen Deb 7859478938 namesixteen@gmail.com Sixteen 2018-12-08T14:42:49-06:00
9 NameFifteen Chan 8758905789 namefifteen@gmail.com Fifteen 2018-12-08T14:41:53-06:00
10 NameFourteen Kimmel 7865749046 namefourteen@gmail.com Fourteen 2018-12-08T14:40:51-06:00
11 NameThirteen Jackson 6789564567 namethirteen@gmail.com Thirteen 2018-12-08T14:37:59-06:00
12 NameTwelve Roy 5643789567 nameatwelve@gmail.com Twelve 2018-12-08T14:04:51-06:00
13 NameEleven Sarkar 7678956745 nameeleven@gmail.com Eleven 2018-12-08T14:03:59-06:00
14 NameTen Maheshwari 8796568987 nameten@gmail.com Ten 2018-12-08T14:02:05-06:00
15 NameNine Mehta 7657875357 namenine@gmail.com Nine 2018-12-08T14:01:19-06:00
16 NameEight Ahmed 6758947383 nameeight@gmail.com Eight 2018-12-08T14:00:29-06:00
17 NameSeven Gogoi 6759483789 nameseven@gmail.com Seven 2018-12-08T13:59:38-06:00
18 NmaeSix Pait 6759738399 namesix@gmail.com Six 2018-12-08T13:58:56-06:00
19 NameFive Roshan 6784637909 namefive@gmail.com Five 2018-12-08T13:58:14-06:00
20 NameTwo Sharma 8578936765 nametwo@gmail.com Two 2018-12-08T13:55:55-06:00
21 NameOne Singh 7859473939 nameone@gmail.com One 2018-12-08T13:55:05-06:00