Skip to content

Commit c02207f

Browse files
committed
update urlencode
1 parent 8470eb3 commit c02207f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
attributes:
22
-
3-
name: distance
3+
name: distance_address
44
type: string
5-
description: A URL-encoded string representing the starting location for the search. This must be specific (e.g., including city, postal code, and country) for accurate results. Ensure the address is properly encoded, where spaces are replaced with `%20`, commas with `%2C`, and other special characters are handled accordingly.
5+
description: A URL-encoded string representing the starting location for the search. This must be specific (e.g., including city, postal code, and country) for accurate results. Ensure the address is properly URL-encoded.
66
-
7-
name: radius
7+
name: distance_radius
88
type: integer
99
description: The radius in kilometers around the distance_address to filter users. Users outside this radius will not be included.
1010

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import pprint
22
import requests
3+
from urllib.parse import urlencode
34

45
headers = {'Authorization': 'token <API KEY>'}
5-
url = (
6-
'https://secure.tutorcruncher.com/api/contractors/'
7-
'?distance_address=The%20Food%20Exchange%2C%20New%20Covent%20Garden%20Market%2C%20Nine%20Elms%2C%20London%20SW8%205EL%2C%20ENGLAND'
8-
'&distance_radius=1'
9-
)
6+
params = {
7+
'distance_address': 'The Food Exchange, New Covent Garden Market, Nine Elms, London SW8 5EL, ENGLAND',
8+
'distance_radius': 1
9+
}
10+
url = f"https://secure.tutorcruncher.com/api/contractors/?{urlencode(params)}"
1011
response = requests.get(url, headers=headers)
1112
pprint.pprint(response.json())
12-

0 commit comments

Comments
 (0)