Curl is working but urllib2 fails in python
Question: I am working on Zomato API for my application, when I hit request using curl I
get the correct response but when I try same using urllib2 I get different
answer.

**Curl Request**

    
    
    import os
    def callCurl():
        os.popen('curl -X GET --header "Accept: application/json" --header "user_key: key" "https://developers.zomato.com/api/v2.1/geocode?lat=18.5363242&lon=73.8932641" > out.txt')
        f = open("out.txt")
        text = f.read()
        print text
    

**Output**

    
    
    {"location":{"entity_type":"","entity_id":0,"title":"Koregaon Park","latitude":"18.5363242000","longitude":"73.8932641000","city_id":5,"city_name":"Pune","country_id":1,"country_name":"India"},"popularity":{"popularity":"4.88","nightlife_index":"4.92","nearby_res":["11135","6504409","10750","10987","11520","10143","10699","10213","10580"],"top_cuisines":["North Indian","Fast Food","Italian","Desserts","Chinese"],"popularity_res":"100","nightlife_res":"10","subzone":"Koregaon Park","subzone_id":3307,"city":"Pune"},"link":"https:\/\/www.zomato.com\/pune\/koregaon-park-restaurants?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","nearby_restaurants":{"1":{"restaurant":{"R":{"res_id":11135},"apikey":"key","id":"11135","name":"Uncle's Chinese","url":"https:\/\/www.zomato.com\/pune\/uncles-chinese-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"3 & 5, A\/10, Meera Garden Society, Lane 7, Off North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5374166667","longitude":"73.9000250000","zipcode":"0","country_id":1},"cuisines":"Chinese, Thai","average_cost_for_two":550,"price_range":2,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/chains\/5\/11135\/3450ffa45030801aa2f4934fe77b280e_featured_thumb.jpg","user_rating":{"aggregate_rating":"3.7","rating_text":"Very Good","rating_color":"5BA829","votes":638},"photos_url":"https:\/\/www.zomato.com\/pune\/uncles-chinese-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/uncles-chinese-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/5\/11135\/db4bce431acbbe60afba5a6e8b39719e_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/11135","order_url":"https:\/\/www.zomato.com\/pune\/uncles-chinese-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/uncles-chinese-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"2":{"restaurant":{"R":{"res_id":6504409},"apikey":"key","id":"6504409","name":"Effingut Brewerkz","url":"https:\/\/www.zomato.com\/pune\/effingut-brewerkz-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"21\/A , Plot 389, Lane Number 6, Serene Bay, Koregaon Park, Pune 411001","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5342194444","longitude":"73.8984916667","zipcode":"411001","country_id":1},"cuisines":"Continental, North Indian, Mughlai, Burmese","average_cost_for_two":2000,"price_range":4,"currency":"Rs.","offers":[],"zomato_events":[{"event":{"event_id":46679,"start_date":"2016-02-18","end_date":"2016-02-18","end_time":"23:00:00","start_time":"20:00:00","is_active":1,"date_added":"2015-09-10 15:58:04","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/1af\/d672fcb7f03e257ad51006d2a38781af_1441880884.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/1af\/d672fcb7f03e257ad51006d2a38781af_1441880884_thumb.jpg","order":0,"md5sum":"d672fcb7f03e257ad51006d2a38781af","photo_id":88657,"uuid":1441880565992433,"type":"NORMAL"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/6504409","title":"Pub Quiz - Every Thursday","description":"#ThirstyThursday is back! Answer simple questions and win Effingut beer! Questions on Sports, sitcoms, movies, food, drinks and a lot more! \r\nHow thirsty are you this Thursday? ;)","display_time":"08:00 pm - 11:00 pm","display_date":"18 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":0,"event_category_name":"","book_link":""}}],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/9\/6504409\/ab9ffd804fa06c820ee0aba93161e9b9_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"4.4","rating_text":"Excellent","rating_color":"3F7E00","votes":829},"photos_url":"https:\/\/www.zomato.com\/pune\/effingut-brewerkz-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/effingut-brewerkz-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/9\/6504409\/ab9ffd804fa06c820ee0aba93161e9b9_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":0,"deeplink":"zomato:\/\/r\/6504409","events_url":"https:\/\/www.zomato.com\/pune\/effingut-brewerkz-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"3":{"restaurant":{"R":{"res_id":10750},"apikey":"key","id":"10750","name":"Dario's","url":"https:\/\/www.zomato.com\/pune\/darios-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"Sundarban Hotel, Lane 1, Off North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5375833333","longitude":"73.8885194444","zipcode":"0","country_id":1},"cuisines":"Italian, Cafe, Salad, Healthy Food","average_cost_for_two":1800,"price_range":3,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/10750\/05965fda1b86a06071c8312b33466ca0_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"4.3","rating_text":"Excellent","rating_color":"3F7E00","votes":1761},"photos_url":"https:\/\/www.zomato.com\/pune\/darios-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/darios-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/10750\/05965fda1b86a06071c8312b33466ca0_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/10750","order_url":"https:\/\/www.zomato.com\/pune\/darios-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/darios-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"4":{"restaurant":{"R":{"res_id":10987},"apikey":"key","id":"10987","name":"Cafe 1730","url":"https:\/\/www.zomato.com\/pune\/cafe-1730-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"21\/1, Serene Bay, Lane 6, Off North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5341833333","longitude":"73.8982777778","zipcode":"0","country_id":1},"cuisines":"European, Continental, North Indian, Goan, Cafe","average_cost_for_two":2000,"price_range":4,"currency":"Rs.","offers":[],"zomato_events":[{"event":{"event_id":55453,"start_date":"2016-01-02","end_date":"2016-02-29","end_time":"21:00:00","start_time":"11:00:00","is_active":1,"date_added":"2016-01-02 13:14:33","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/9e2\/e210d91c583b9aeafa90930e7134b9e2_1455112161.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/9e2\/e210d91c583b9aeafa90930e7134b9e2_1455112161_thumb.jpg","order":0,"md5sum":"e210d91c583b9aeafa90930e7134b9e2","photo_id":107008,"uuid":14551121586638,"type":"FEATURED"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/404\/7500c47cc5571bf24c115a8a64273404_1448960204.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/404\/7500c47cc5571bf24c115a8a64273404_1448960204_thumb.jpg","order":1,"md5sum":"7500c47cc5571bf24c115a8a64273404","photo_id":102274,"uuid":14517206735387,"type":"NORMAL"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/10987","title":"Steal The Bar","description":"-PITCHERS-\r\n*Its Not A Beer 999\/-\r\n*Lemon Tarika 999\/-\r\n*Sweet Lime & Jalapeno 999\/-\r\n*Pink Panthers 1399\/-\r\n*The Idol Eyes 1399\/-\r\n*1730 Jubilee 1199\/-\r\n*Long Island Iced Tea 1399\/-\r\n*Cosmopolitan 1099\/-\r\n*Mojito 1199\/-\r\n*Apple Sangria 1099\/-\r\n*Fresh Lime Martini 1099\/-\r\n\r\n-BAR DEALS-\r\n*Beer glass 79\/-\r\n*Beer Tower 669\/-\r\n*Kingfisher beer bucket 599\/-\r\n*K.f. ultra bucket 749\/-\r\n*Domestic whisky 675\/-\r\n(Blenders pride\/antiquity blue\/signature premium 3.60ml)\r\n*Bacardi \/vodka 699\/-\r\n(3.60ml)\r\n*Dark rum 399\/-\r\n(3.60ml)\r\n*Regular scotch 999\/-\r\n(Teachers highland cream\/teachers50\/vat69\/ballantines)\r\n(3.60ml)\r\n*Premium vodka 1399\/-\r\n(Absolut flavors \/ absolut \/ketelone)3.60ml","display_time":"11:00 am - 09:00 pm","display_date":"02 January - 29 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":0,"event_category_name":"","book_link":""}},{"event":{"event_id":57508,"start_date":"2016-01-28","end_date":"2016-02-29","end_time":"15:30:59","start_time":"11:00:59","is_active":1,"date_added":"2016-01-28 14:42:18","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/6e7\/69ad1cdd77bd8ca27542ccd41198b6e7_1453972338.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/6e7\/69ad1cdd77bd8ca27542ccd41198b6e7_1453972338_thumb.jpg","order":0,"md5sum":"69ad1cdd77bd8ca27542ccd41198b6e7","photo_id":105186,"uuid":14539722884108,"type":"FEATURED"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/b41\/a9f64768cd738199608dac752f666b41_1453972338.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/b41\/a9f64768cd738199608dac752f666b41_1453972338_thumb.jpg","order":1,"md5sum":"a9f64768cd738199608dac752f666b41","photo_id":105187,"uuid":14539722884067,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/4a7\/992edf24f98a656d79d95e4d2ddd24a7_1453972339.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/4a7\/992edf24f98a656d79d95e4d2ddd24a7_1453972339_thumb.jpg","order":2,"md5sum":"992edf24f98a656d79d95e4d2ddd24a7","photo_id":105188,"uuid":14539722885523,"type":"NORMAL"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/10987","title":"The LunchPad Menu","description":"With Modesty of melting meat and the gratitude of the smoky fire,the best of all times.\nFor ultimate experience.To make the memorable lunch.\nWe bring you The LunchPad Menu !!!\n\nMonday To Friday \n\"A 5 course Meal\"\nFor Herbivores - 449\/-\nFor Carnivores - 499\/-\n(Taxes as applicable)\n\n","display_time":"11:00 am - 03:30 pm","display_date":"28 January - 29 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":1,"event_category_name":"","book_link":""}},{"event":{"event_id":59367,"start_date":"2016-02-20","end_date":"2016-02-20","end_time":"23:00:31","start_time":"19:00:31","is_active":1,"date_added":"2016-02-14 19:49:44","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/fdd\/b8c3b540f657231cb9d847075e87dfdd_1448447011.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/fdd\/b8c3b540f657231cb9d847075e87dfdd_1448447011_thumb.jpg","order":0,"md5sum":"b8c3b540f657231cb9d847075e87dfdd","photo_id":107705,"uuid":14554595836638,"type":"FEATURED"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/10987","title":"Saturday night live with \"Mike\"","description":"So what could your weekend look like?\nFrom the moment you arrive you can sit back and relax,\nWe have thought of everything,\nThere is something for everyone.\nFor all those music lovers we have got a live act by \"Mike\"\nFor foodies treat yourself with our scrumptious continental and Goan cuisine and for our beers lovers we have offer all night.\nIsn't this a perfect weekend for you all?","display_time":"07:00 pm - 11:00 pm","display_date":"20 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":1,"event_category_name":"","book_link":""}},{"event":{"event_id":59368,"start_date":"2016-02-21","end_date":"2016-02-21","end_time":"16:00:57","start_time":"11:00:57","is_active":1,"date_added":"2016-02-14 19:50:12","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/57e\/d4a8cbcea29b6ae31f786ae62fa8557e_1448446788.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/57e\/d4a8cbcea29b6ae31f786ae62fa8557e_1448446788_thumb.jpg","order":0,"md5sum":"d4a8cbcea29b6ae31f786ae62fa8557e","photo_id":107706,"uuid":14554596124108,"type":"FEATURED"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/10987","title":"Cafe1730 Sunday Brunch","description":"unlimited food only @699 \/-\nunlimited food, beer and wine @959 \/- \nUnlimited food, beer and imfl @1599 \/-\n(Taxes as applicable)\n\nThe perfect Sunday awaits you at cafe1730.Meet up with family and friends in a relaxed ambiance, enjoying the most delicious brunch dishes and best wines in town.\n\n  \nThe feast opens with a spectacular brunch of fresh salads, home made pastries and the best local fishes and cheeses. But there is more, The al a carte brunch menu offers a definite selection of seasonally inspired brunch dishes. The Sunday is completed with the delightful dessert table full of treats no one should miss the Pure indulgence.\nAnd not to forget we have live act by Austin Fernandes just to keep your feet tapping... \n\n","display_time":"11:00 am - 04:00 pm","display_date":"21 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":1,"event_category_name":"","book_link":""}}],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/7\/10987\/92a13cb47c42ff9f7b9717cb7fedba2a_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"4.0","rating_text":"Very Good","rating_color":"5BA829","votes":925},"photos_url":"https:\/\/www.zomato.com\/pune\/cafe-1730-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/cafe-1730-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/7\/10987\/92a13cb47c42ff9f7b9717cb7fedba2a_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/10987","order_url":"https:\/\/www.zomato.com\/pune\/cafe-1730-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/cafe-1730-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"5":{"restaurant":{"R":{"res_id":11520},"apikey":"key","id":"11520","name":"The Burger House","url":"https:\/\/www.zomato.com\/pune\/the-burger-house-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"A\/1, Rahul Terrace, Ground Floor, Lane 7, Meera Nagar, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5366388889","longitude":"73.9000638889","zipcode":"0","country_id":1},"cuisines":"American, Fast Food, Burger","average_cost_for_two":400,"price_range":1,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/11520\/6f486dcc6e8877b408f942896322882e_res_featured_thumb.JPG","user_rating":{"aggregate_rating":"3.6","rating_text":"Very Good","rating_color":"5BA829","votes":788},"photos_url":"https:\/\/www.zomato.com\/pune\/the-burger-house-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/the-burger-house-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/11520\/6f486dcc6e8877b408f942896322882e_featured_v2.JPG","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/11520","order_url":"https:\/\/www.zomato.com\/pune\/the-burger-house-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/the-burger-house-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"6":{"restaurant":{"R":{"res_id":10143},"apikey":"key","id":"10143","name":"Arthur's Theme","url":"https:\/\/www.zomato.com\/pune\/arthurs-theme-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"2, Vrindavan Apartment, Lane 6, Off North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5385388889","longitude":"73.8986805556","zipcode":"0","country_id":1},"cuisines":"European, Italian","average_cost_for_two":1300,"price_range":3,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/3\/10143\/2ca672418c2a9d664c5bc2ced4ab7cb7_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"4.3","rating_text":"Excellent","rating_color":"3F7E00","votes":1553},"photos_url":"https:\/\/www.zomato.com\/pune\/arthurs-theme-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/arthurs-theme-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/3\/10143\/2ca672418c2a9d664c5bc2ced4ab7cb7_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/10143","order_url":"https:\/\/www.zomato.com\/pune\/arthurs-theme-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/arthurs-theme-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"7":{"restaurant":{"R":{"res_id":10699},"apikey":"key","id":"10699","name":"Prem's","url":"https:\/\/www.zomato.com\/pune\/prems-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"28\/2, SBI Training Centre, North Main Road, Koregaon Park, Pune 411001","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5396583333","longitude":"73.8934388889","zipcode":"411001","country_id":1},"cuisines":"North Indian, Chinese, Continental","average_cost_for_two":1200,"price_range":3,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/9\/10699\/1154483951e226d02d7746e349cf65a5_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"3.9","rating_text":"Very Good","rating_color":"5BA829","votes":1299},"photos_url":"https:\/\/www.zomato.com\/pune\/prems-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/prems-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/9\/10699\/1154483951e226d02d7746e349cf65a5_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":0,"deeplink":"zomato:\/\/r\/10699","events_url":"https:\/\/www.zomato.com\/pune\/prems-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"8":{"restaurant":{"R":{"res_id":10213},"apikey":"key","id":"10213","name":"Malaka Spice","url":"https:\/\/www.zomato.com\/pune\/malaka-spice-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"Lane 5, Opposite Oxford Properties, North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5374333333","longitude":"73.8974833333","zipcode":"","country_id":1},"cuisines":"Malaysian, Thai, Vietnamese, Japanese, Korean, Asian","average_cost_for_two":2000,"price_range":4,"currency":"Rs.","offers":[],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/chains\/3\/10213\/6a645a5fa205af3ece1512c9c38b923e_featured_thumb.jpg","user_rating":{"aggregate_rating":"4.4","rating_text":"Excellent","rating_color":"3F7E00","votes":2568},"photos_url":"https:\/\/www.zomato.com\/pune\/malaka-spice-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/malaka-spice-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/3\/10213\/5e3195141eb36f299e217f6e2e477d61_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/10213","order_url":"https:\/\/www.zomato.com\/pune\/malaka-spice-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/malaka-spice-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},"9":{"restaurant":{"R":{"res_id":10580},"apikey":"key","id":"10580","name":"Hidden Place - The Hangout","url":"https:\/\/www.zomato.com\/pune\/hidden-place-the-hangout-koregaon-park?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"2 & 3, Upper Ground Floor, Gera Legend, North Main Road, Koregaon Park, Pune","locality":"Koregaon Park","city":"Pune","city_id":5,"latitude":"18.5396694444","longitude":"73.8871611111","zipcode":"0","country_id":1},"cuisines":"Finger Food, North Indian, Continental","average_cost_for_two":1000,"price_range":3,"currency":"Rs.","offers":[],"zomato_events":[{"event":{"event_id":48384,"start_date":"2016-02-02","end_date":"2016-02-29","end_time":"20:00:00","start_time":"12:00:00","is_active":1,"date_added":"2015-10-06 19:16:54","photos":[{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/c26\/920f6523684454ea62d88911b03f0c26_1446448276.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/c26\/920f6523684454ea62d88911b03f0c26_1446448276_thumb.jpg","order":0,"md5sum":"920f6523684454ea62d88911b03f0c26","photo_id":93464,"uuid":1446448240937387,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/5b8\/5485e985778bff879cb4617f43dcf5b8_1446448276.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/5b8\/5485e985778bff879cb4617f43dcf5b8_1446448276_thumb.jpg","order":1,"md5sum":"5485e985778bff879cb4617f43dcf5b8","photo_id":93465,"uuid":1446448241675278,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/bde\/ef0075476a283bbd14c1b8fa4c976bde_1448867798.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/bde\/ef0075476a283bbd14c1b8fa4c976bde_1448867798_thumb.jpg","order":2,"md5sum":"ef0075476a283bbd14c1b8fa4c976bde","photo_id":96026,"uuid":1448867064602104,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/d1b\/3ebbfdee1673aa337f4fdaed3fd08d1b_1448867799.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/d1b\/3ebbfdee1673aa337f4fdaed3fd08d1b_1448867799_thumb.jpg","order":3,"md5sum":"3ebbfdee1673aa337f4fdaed3fd08d1b","photo_id":96027,"uuid":1448867203422890,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/bd6\/4e773de66328c7d01405c6edb8d5abd6_1448867799.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/bd6\/4e773de66328c7d01405c6edb8d5abd6_1448867799_thumb.jpg","order":4,"md5sum":"4e773de66328c7d01405c6edb8d5abd6","photo_id":96028,"uuid":1448867203988532,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/c75\/01c952e8c4e7c595136c96bcba27dc75_1452491019.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/c75\/01c952e8c4e7c595136c96bcba27dc75_1452491019_thumb.jpg","order":5,"md5sum":"01c952e8c4e7c595136c96bcba27dc75","photo_id":103147,"uuid":1452490989772374,"type":"NORMAL"}},{"photo":{"url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/f97\/52f544fa43b2ca7428274f453c82af97_1448867800.jpg","thumb_url":"https:\/\/b.zmtcdn.com\/data\/zomato_events\/photos\/f97\/52f544fa43b2ca7428274f453c82af97_1448867800_thumb.jpg","order":6,"md5sum":"52f544fa43b2ca7428274f453c82af97","photo_id":96030,"uuid":1448867725107894,"type":"NORMAL"}}],"restaurants":[],"is_valid":1,"share_url":"http:\/\/www.zoma.to\/r\/13011","title":"An OFFER UNHEARD OF - A Pint for Rs.92*\/Pint or A Litre for Rs.166*\/Litre","description":"Get a Pint for Rs.92*\/Pint (On a Bucket of 6 Pints) or a Litre for Rs. 166*\/Litre (6L Towers) at The Crazy Frog (DP Road) and The Hangout (Kothrud)! Offer available up to 8pm EVERYDAY at both the outlets! Crazy offer isn't it? \r\n\r\nAlso, whether is your Birthday or NOT, we're giving you an offer you can't refuse! :P Here's what we have to offer in our Birthday Bonker Bash for INR 5999*\/- - 2 Kingfisher Towers - 1 Bottle Smirnoff Vodka OR Smirnoff Vodka Flavor - 1 Bottle Signature OR Royal Challenge OR Caribbean Legend Rum - 1 Bottle Champagne Prosecco OR 2 Bottle RIO Sparking (375ML X 2) - Mixers. Need we say more? ;)\r\n\r\n*T&C Apply! Legal age is mandatory.","display_time":"12:00 pm - 08:00 pm","display_date":"02 February - 29 February","is_end_time_set":1,"disclaimer":"Restaurants are solely responsible for the service; availability and quality of the events including all or any cancellations\/ modifications\/ complaints.","event_category":0,"event_category_name":"","book_link":""}}],"thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/10580\/70f30d18d32c58e2a9307d6f79419b6e_res_featured_thumb.jpg","user_rating":{"aggregate_rating":"3.9","rating_text":"Very Good","rating_color":"5BA829","votes":2297},"photos_url":"https:\/\/www.zomato.com\/pune\/hidden-place-the-hangout-koregaon-park\/photos#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","menu_url":"https:\/\/www.zomato.com\/pune\/hidden-place-the-hangout-koregaon-park\/menu#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/0\/10580\/70f30d18d32c58e2a9307d6f79419b6e_featured_v2.jpg","has_online_delivery":1,"is_delivering_now":1,"deeplink":"zomato:\/\/r\/10580","order_url":"https:\/\/www.zomato.com\/pune\/hidden-place-the-hangout-koregaon-park\/order?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","order_deeplink":"","events_url":"https:\/\/www.zomato.com\/pune\/hidden-place-the-hangout-koregaon-park\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}}}}
    

**urllib2 Request**

    
    
    import urllib
    import urllib2
    import json
    def callUrllib():
        values = {"lat" : "18.5363242", "lon":"73.8932641"}
        headers = {'Accept': 'application/json', 'user_key' : "key"}
        data = urllib.urlencode(values)
        req = urllib2.Request("https://developers.zomato.com/api/v2.1/geocode", data, headers)
        response = urllib2.urlopen(req)
        the_page = response.read()
        print json.loads(the_page)
    

**Output**

    
    
    {"location":{"entity_type":"","entity_id":0,"title":"Koregaon Park","latitude":"18.5363242000","longitude":"73.8932641000","city_id":5,"city_name":"Pune","country_id":1,"country_name":"India"},"popularity":{"status":"failed","message":"Coordinates missing","nightlife_index":0,"popularity":0},"link":"https:\/\/www.zomato.com\/pune\/koregaon-park-restaurants?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","nearby_restaurants":[]}
    

Using urllib2 I am not getting value for key **nearby_restaurants**. Why both
are giving different output? Am I doing it correctly? Please Help :)


Answer: You are actually doing here `POST` request with python. That's why your
latitude longitude is not accepted by the server as they were sending as
`POST`. If you use NULL value for the `data` it would return same I believe.

To achieve `GET` use following. Here I am adding the data with the url as GET
and sending empty value for second parameter.

    
    
    req = urllib2.Request("https://developers.zomato.com/api/v2.1/geocode?"+data, '', headers)
    

