How to call Rest API and use the data in that API?

Maham :

I have a scenario where I will open my website and than I have to call the Rest API where in that API I will be needing some data, like user name,password and some URLs. The purpose of calling API is that I dont know the credentials as well as the URLS which is going to get check and every time these data will get change therefore I will just call an API. Below is my Selenium Python

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# declare variable to store the URL to be visited
base_url="https://www.fitotouch.com/qitouch"

driver = webdriver.Chrome('E:/Chrome driver/chromedriver.exe')
driver.maximize_window()
#function of our 'driver' object.
driver.implicitly_wait(10) #10 is in seconds
driver.get(base_url)
driver.implicitly_wait(10)
driver.find_element_by_name('password').send_keys("*****")
driver.implicitly_wait(10)
driver.find_element_by_class_name('arrow-icon').click()

After above click command I have to call API and Login from the data given in the API.

My API is : http://110.93.230.117:1403/api/order/5e439b7052fcf2189ccb5207

If I can get solution in Java than also it is Fine.

enter image description here

Guy :

Use requests module to get the data as dictionary, from there you can get the values by the key

import requests

data = requests.get('http://110.93.230.117:1403/api/order/5e439b7052fcf2189ccb5207').json()
print(data)

"""
{'date': '2020-02-12T06:30:08.106Z',
 '_id': '5e439b7052fcf2189ccb5207',
 'fitoName': 'Chinasor 01 - Bu Yang Huan Wu Wan',
 'fitoCode': 'Chinasor 01',
 'providerName': 'Soria - Chinasor',
 'providerCode': 'Chinasor 01',
 'valueItem': '01',
 'Email': '[email protected]',
 '__v': 0}
"""

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=18995&siteId=1