1
I have a project to capture Atms next to a coordinate on the Mastercard website form. I can bring the result but not in json. By Content-Type be text.XML, should not allow to bring result in json? Or result will always be HTML and need to apply Beautifulsoap in response?
Source https://www.mastercard.pt/pt-pt/consumers/get-support/locate-an-atm.html
import requests
params = {'latitude': -23.4887194, 'longitude': -46.6701079, 'radius': 5, 'distanceUnit': 1,
'locationType': 'atm', 'maxLocations': "", 'instName': "", 'supportEMV': "", 'customAttr1': "",
'locationTypeId': ""}
r = requests.get('https://www.mastercard.pt/locator/NearestLocationsService/', params=params)
r.json()
ERROR
ssss ---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-41-52b7ec8d97cc> in <module>
----> 1 r.json()
~\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)
896 # used.
897 pass
898 return complexjson.loads(self.text, **kwargs)
899
900 @property
~\Anaconda3\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int,
parse_constant, object_pairs_hook, **kw)
K 355 parse_int is None and parse_float is None and
356 parse_constant is None and object_pairs_hook is None and not kw):
357 return _default_decoder.decode(s)
358 if cls is None:
359 cls = JSONDecoder
~\Anaconda3\lib\json\decoder.py in decode(self, s, _w)
335
336
337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
~\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
xml is another format to carry data, it is very similar to json. You will need a lib of your own to handle xml. I will search here
– William Teixeira
Why don’t you use the bilioteca they provide??? See here
– Paulo Marques