Home > Software design >  Reading Data from web using python
Reading Data from web using python

Time:01-14

response_object = requests.get("https://testnet.binance.vision/api/v3/exchangeInfo")


response = response_object.json()


response

can we read this file in pandas dataframe,its shows wired data when i convert this in pandas data frame or any other way to read this data in python?

CodePudding user response:

You can tabularize the data and place it into a dataframe using json_normalize:

df = json_normalize(data)

CodePudding user response:

Developers using BeatifulSoup For Parsing HTML elements you should use that ! It is easy

For Example :

and if you want i can send you a video link for watch

import time
import requests 
from bs4 import BeautifulSoup 
from time import sleep
from googletrans import Translator

Translator = Translator()


appOpen = True

while appOpen == True:
    time.sleep(2.5)

    url = "https://www.worldometers.info/coronavirus/country/bulgaria/" #Site Url 
    R = requests.get(url) # For Enter Website

    

    Soup = BeautifulSoup(R.text) # For Parsing

    


    casesDiv = Soup.find("div", {"class" : "news_post"}) # To Fınd a Element from HTML

    casesDiv.findChildren("li", {"class" : "news_li"})

    TransSentences = casesDiv.text

    translation = Translator.translate(TransSentences, dest="tr", src="en")

    

    print(f"{translation.text}".upper())

CodePudding user response:

First of all, read the request response as json:

response_data = response_object.json()

This would create a Python dict with the response data. Then parse the dict in order to get the structure to create Pandas dataframe from.

Then use any of the following methods to convert the structure into DataFrame:

  •  Tags:  
  • Related