Skip to content

Instantly share code, notes, and snippets.

View hassanabidpk's full-sized avatar
๐ŸŽฏ
Focusing

Hassan Abid hassanabidpk

๐ŸŽฏ
Focusing
  • Singapore
View GitHub Profile
from bs4 import BeautifulSoup
import requests
import re
import csv
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
let params = ["location": locationStr,"rtype": escapedRestaurantValue]
Alamofire.request(.GET, API_BASE_URL, parameters: params)
.responseJSON { response in
if let restaurants = response.result.value {
print("JSON: \(restaurants)")
if let error = restaurants["error"] {
print("No venue found | error :\(error)")
self.restaurantName.text = "Nothing found! Try again"
self.stopSpinner(nil)
return
[
{"name":"Peppes Pizza",
"latitude":"59.911342",
"longitude":"10.749586",
"address":"Karl Johans gate 1 (Jernbanetorget) 0154 Oslo Norge",
"photo_url":"https://irs0.4sqi.net/img/general/455x300/1089036_6y6hN44be6KeNqnl8hjS-OaLpV6i0bF-h_yXQJ5nzEQ.jpg",
"phone_number":"+47 22 22 55 55",
"venue_id":"4b67301bf964a52038402be3",
"checkins":1025,
"r_type":"pizza",
# required imports
def getRestaurantList(ilocation,query):
#....
# code implementation can be seen here https://github.com/hassanabidpk/searchrestaurant/blob/master/django/searchrestaurant/search/views.py
return result
class RestaurantList(APIView):
def get(self,request,format=None):
if "location" in request.GET and "rtype" in request.GET:
from django.contrib.auth.models import User, Group
from rest_framework import serializers
from .models import Location,Restaurant
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
Common Endpoints
  • Get list of all restaurants: /api/v1/
  • Get list of restaurants for particular location and type: /api/v1/ with params location and rtype
  • Sample Request: https://searchrestaurant.pythonanywhere.com/api/v1/?format=json&location=oslo&rtype=pizza
Response Values
  • In case of error you will get an error key with a status code
  • You will get an array of dicts eaching containing information about place(restaurant,coffee shop etc.)
@hassanabidpk
hassanabidpk / sujinlee_weather_yahoo.py
Created November 29, 2015 14:29 — forked from allieus/sujinlee_weather_yahoo.py
์ด์ˆ˜์ง„๋‹˜ ๋‚ ์”จ ์Šคํฌ๋ฆฝํŠธ ๊ฐœ์„ 
# https://github.com/sujinleeme/my-python-journey/blob/master/PR4E/yahoo-weatherAPI.py
import requests
def get_weather(city):
baseurl = 'https://query.yahooapis.com/v1/public/yql'
yql_query = "SELECT * FROM weather.forecast WHERE woeid IN (SELECT woeid FROM geo.places(1) WHERE text='%s')" % city
params = {'q': yql_query, 'format': 'json'}
data = requests.get(baseurl, params=params).json()
@hassanabidpk
hassanabidpk / CursorRecyclerViewAdapter.java
Last active September 22, 2015 07:20 — forked from skyfishjy/CursorRecyclerViewAdapter.java
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
DjangoGirls - how we scored applications?
์ง€์›์ž ์ ์ˆ˜์ œ์— ๋Œ€ํ•˜์—ฌ
๊ฐ ์ง€์›์ž์— ๋Œ€ํ•˜์—ฌ 1์ ๋ถ€ํ„ฐ 5์ ๊นŒ์ง€ ์ ์ˆ˜๋ฅผ ๋งค๊ฒผ์Šต๋‹ˆ๋‹ค.
์ ์ˆ˜ ๋ถ€์—ฌ ๋Œ€์ƒ ํ•ญ๋ชฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
โ€ข ์›Œํฌ์ƒต ๋‚ด์šฉ์ด ์ง€์›์ž์—๊ฒŒ ์–ด๋–ค ์‹ค์งˆ์ ์ธ ์ด๋“์„ ์ฃผ๋Š”๊ฐ€?
โ€ข ์›Œํฌ์ƒต ๋‚ด์šฉ์„ ๊ฐ€์ง€๊ณ  ์ง€์›์ž๊ฐ€ ์ถ”ํ›„ ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ์–ด๋–ค (ํ˜„์‹ค์ ์ธ) ๋„์›€์„ ์ค„ ์ˆ˜ ์žˆ๋Š”๊ฐ€?
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query