0

I am new to this and I am working on a project, where i have to get hotel rate and room type from makemytrip.com

1 step - I search Octave hotel in Banglore( India ) in makemytrip.com
2 step - I inspect the browser for json file where i can get the data

I got this url json type url link of Type =application/json which contains data that i wana read but when i read the url using this code

import requests
r = requests.get('https://hotelz.makemytrip.com/makemytrip/site/hotels/detailJsonData?ajaxCall=T&session_cId=1466139781139&city=BLR&country=IN&checkin=06302016&checkout=08072016&searchText=null&area=&roomStayQualifier=1e0e&hotelId=201503101445304217&i=null')
r.headers['content-type']

the type i am getting is text/html instead of application/json

How to read this data ??

Vaibhav
  • 1,154
  • 10
  • 26
  • Just use `json` library and something like `json.loads(r.read())`, There's many questions about this around, take a look e.g. to http://stackoverflow.com/questions/33282067/read-json-response-in-python – lrnzcig Jun 17 '16 at 10:18
  • Are you sure that URL is valid? I get an error page when I visit it using my browser. I suspect the problem is caused by that `session_cId` parameter. – PM 2Ring Jun 17 '16 at 10:24
  • 1. json.loads not working for me and 2. well i go through step 1 and step 2 so i got proper session id and link give me json data in new browser tab – Vaibhav Jun 17 '16 at 10:33

0 Answers0