1

How can I send this curl out using Python? I did find similar requests, but cannot adapt my code to suite the query I have also tried using pycurl, following this example but without luck.

$ curl -v -X GET  -H "Accept: text/csv" -H "Authorization: Basic YW5kcmVhLmJvdHRpQHdzcC5jb206OWY5N2E5YTY2ZWU1MTMxZjdmNjk4MDcwZTFkODEwMjU0M2I0NTg1ZA==" "https://epc.opendatacommunities.org/api/v1/domestic/search"

Thanks

1

1 Answer 1

2

If you are using the Python Requests package the following code snippet should work:

import requests

headers = {
    'Accept': 'text/csv',
    'Authorization': 'Basic YW5kcmVhLmJvdHRpQHdzcC5jb206OWY5N2E5YTY2ZWU1MTMxZjdmNjk4MDcwZTFkODEwMjU0M2I0NTg1ZA==',
}

response = requests.get('https://epc.opendatacommunities.org/api/v1/domestic/search', headers=headers)

response.status_code  # 200
response.text # "lmk-key,address1,address2,address3,postcode,buildi ..."

(Note: I used the https://curl.trillworks.com/ website to automatically make the conversion)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.