Cyber Whale

Python networking example

Here is a small example demonstrating get requests in Python.

networkingpythonrequesttutorialTutorials

Python networking example

Here is a small example demonstrating get requests in Python.

pip install requestspip install requests

And the code itself

import library import requests

#prepare paramteters parameters = {‘date:’:‘2000:2010’, ‘format’:‘xml’}

#prepare URL url = ‘http://api.worldbank.org/countries/br/indicators/SP.POP.TOTL

#call get method and save data into the response r = requests.get(url, params=parameters)

#print the url considering the params print r.url

#check for status code statusCode = int(r.status_code)

#if failed request print the mesage, else print response headers and text if statusCode != 200: print ‘Request Failed’ else: print r.headers[‘content-type’] #print r.json() for json requests print r.textimport library import requests

#prepare paramteters parameters = {‘date:’:‘2000:2010’, ‘format’:‘xml’}

#prepare URL url = ‘http://api.worldbank.org/countries/br/indicators/SP.POP.TOTL

#call get method and save data into the response r = requests.get(url, params=parameters)

#print the url considering the params print r.url

#check for status code statusCode = int(r.status_code)

#if failed request print the mesage, else print response headers and text if statusCode != 200: print ‘Request Failed’ else: print r.headers[‘content-type’] #print r.json() for json requests print r.text

By adminnetworkingpythonrequesttutorial

Recent Posts

Archive

Tags

#CloudTechnologies #Code #CyberWhale #GenerativeAI Analytics bi Big Data Business Business growth business intelligence Cambrian Explosion Cloud data Data Capture Data Management Data Science Data Stack Data Synchronization Data Systems Data Warehouse DBLog deeplearning4j development dev tools DoorDash ELT ETL Hacks java jobs libs machine learning parsing Production python request Retail SaaS scala Strategy tip tutorial Uber word2vec xml

AI Strategy & Consulting

Build a future-ready AI strategy with trusted guidance