How to use Python to execute a cURL command?

For the sake of simplicity, you should consider using the Requests library.

An example with JSON response content would be something like:

import requests
r = requests.get('https://github.com/timeline.json')
r.json()

If you look for further information, in the Quickstart section, they have lots of working examples.

For your specific curl translation:

import requests

url="https://www.googleapis.com/qpxExpress/v1/trips/search?key=mykeyhere"
payload = open("request.json")
headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8'}
r = requests.post(url, data=payload, headers=headers)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)