0

I am very new to Python (and relatively new to programming) and would appreciate any help.

How would I use the following example link to download the supplied information using Python.

https://url.com/InfoService/GetFlightByFlightNum?board={BOARD}&flightNum={FLIGHTNUM}

Method: GET

Thanks

user1494941
  • 175
  • 1
  • 2
  • 9

2 Answers2

1

The most easy way to access APIs from python is using the requests library

You can quickly install it with pip install requests

Then you can do that for your example:

import requests

payload = {'board': {BOARD}, 'flightNum': {FLIGHTNUM}}
r = requests.get('https://url.com/InfoService/GetFlightByFlightNum', params=payload)

# print the response result
print r.text
sp4ke
  • 549
  • 2
  • 12
0

You can use the builtin library urllib2.

Python 2 documentation: http://docs.python.org/2/library/urllib2.html

Python 3 documentation: http://docs.python.org/3.1/howto/urllib2.html

Here are some examples: How do I download a file over HTTP using Python?

Community
  • 1
  • 1
twasbrillig
  • 17,084
  • 9
  • 43
  • 67