In [3]:
import folium

In [2]:
import folium

map_osm = folium.Map(location=[37.7549, -122.4194], zoom_start=13, detect_retina=True, 
                    tiles='http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg', attr='Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.')    
                  
map_osm.add_tile_layer(tile_url='http://tile.stamen.com/toner-labels/{z}/{x}/{y}.png', attr='labels',
                       active=True, overlay=True)

html = r'''<div align="center"> <font size="5"><b>test2</b></font> <br><img src="http://planck.ucsc.edu/images/insight/VRGLWJryfUIlYH_woaLkHw.png" alt="NOPE" style="width:200px;height:200px;"></div>'''

iframe = folium.element.IFrame(html=html,width=250,height=250)
popup = folium.Popup(html=iframe)

#popup = folium.Popup(html, max_width=300)
icon = folium.Icon(color="blue", icon="ok")
marker1 = folium.Marker(location=[37.7549, -122.4194], popup=popup, icon=icon)
map_osm.add_children(marker1)

icon = folium.Icon(color="blue", icon="ok")
marker2 = folium.Marker(location=[37.7449, -122.4194], popup=popup, icon=icon)
map_osm.add_children(marker2)



map_osm.save('/home/carlson/web/images/insight/map.html')
map_osm


Out[2]:

In [1]:
import folium
from folium import plugins

print(folium.__file__)
print(folium.__version__)

import numpy as np

data = (np.random.normal(size=(100, 3)) *
        np.array([[1, 1, 1]]) +
        np.array([[48, 5, 1]])).tolist()
mapa = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)
mapa.add_children(plugins.HeatMap(data))
mapa


/home/carlson/anaconda/envs/insight/lib/python2.7/site-packages/folium/__init__.pyc
0.2.1
Out[1]:

In [110]:


In [ ]:


In [113]:
import pandas as pd
bus_df = pd.read_pickle('../input/yelp_academic_dataset_business.pickle')

In [117]:
bus_df.business_id=='VRGLWJryfUIlYH_woaLkHw'
lat = bus_df.latitude[bus_df.business_id=='VRGLWJryfUIlYH_woaLkHw'].values[0]
lon = bus_df.longitude[bus_df.business_id=='VRGLWJryfUIlYH_woaLkHw'].values[0]

In [118]:
print lat, lon


36.1044875 -115.1767584

In [104]:
import sys 
sys.path.append('../vectorsearch/')
import vectorsearch 
import pandas as pd


df_businesses = pd.read_pickle('../input/yelp_academic_dataset_business_SF.pickle')
def get_bus_ids_city_state(city, state):
    bids =  set(list(df_businesses.business_id[(df_businesses.city==city) 
                                     & (df_businesses.state==state)].values))
    return bids

bids_in_city_state = get_bus_ids_city_state('San Francisco', 'CA')
print len(bids_in_city_state)
rev_topic = vectorsearch.GetDocTopic('Oysters, cocktails, peir, alcatraz')
bids, sims = vectorsearch.FindBusinessSimilarityLDA(rev_topic, business_ids=bids_in_city_state, top_n=30, method='Hel')


1035

In [109]:
import folium
from folium import plugins

print(folium.__file__)
print(folium.__version__)

import numpy as np

# data = (np.random.normal(size=(100, 3)) *
#         np.array([[1, 1, 1]]) +
#         np.array([[48, 5, 1]])).tolist()

heatmap_events = [(df_businesses.latitude[df_businesses.business_id==bus_id].values[0], 
                   df_businesses.longitude[df_businesses.business_id==bus_id].values[0], 
                   -sims[i]+sims[0]) for i, bus_id in enumerate(bids)]

lats = sims_array = np.array(heatmap_events)[:,0]
lons = sims_array = np.array(heatmap_events)[:,1]
sims_array = np.array(heatmap_events)[:,2]
scale = sims[3]-sims[0]
sims_array = ((1-1/(np.exp(sims_array/scale)+1))*50).astype(np.int32)

heatmap = [] 
for i, sim in enumerate(sims_array):
    for j in range(sim):
        heatmap += [[lats[i]+.00001*j, lons[i]]]
#print heatmap
# heatmap_events = zip(lats,lons,sims_array)

# for event in heatmap:
#     print event

mapa = folium.Map([37.7549, -122.4194], tiles='stamentoner', zoom_start=12,)


# heatmap = [[37.7549, -122.4194]]*10 + [[37.7549, -122.6194]]
# print heatmap
print heatmap
mapa.add_children(plugins.HeatMap(heatmap, max_zoom=18, radius=25, max_val=20))
mapa


/home/carlson/anaconda/envs/insight/lib/python2.7/site-packages/folium/__init__.pyc
0.2.1
[[37.756095886230497, -122.41845703125], [37.7561058862305, -122.41845703125], [37.756115886230496, -122.41845703125], [37.7561258862305, -122.41845703125], [37.756135886230496, -122.41845703125], [37.756145886230499, -122.41845703125], [37.756155886230495, -122.41845703125], [37.756165886230498, -122.41845703125], [37.756175886230494, -122.41845703125], [37.756185886230497, -122.41845703125], [37.7561958862305, -122.41845703125], [37.756205886230497, -122.41845703125], [37.7562158862305, -122.41845703125], [37.756225886230496, -122.41845703125], [37.756235886230499, -122.41845703125], [37.756245886230495, -122.41845703125], [37.756255886230498, -122.41845703125], [37.756265886230494, -122.41845703125], [37.756275886230497, -122.41845703125], [37.756285886230501, -122.41845703125], [37.756295886230497, -122.41845703125], [37.7563058862305, -122.41845703125], [37.756315886230496, -122.41845703125], [37.756325886230499, -122.41845703125], [37.756335886230495, -122.41845703125], [37.725451514124899, -122.402759939432], [37.725461514124902, -122.402759939432], [37.725471514124898, -122.402759939432], [37.725481514124901, -122.402759939432], [37.725491514124897, -122.402759939432], [37.7255015141249, -122.402759939432], [37.725511514124896, -122.402759939432], [37.7255215141249, -122.402759939432], [37.725531514124896, -122.402759939432], [37.725541514124899, -122.402759939432], [37.725551514124902, -122.402759939432], [37.725561514124898, -122.402759939432], [37.725571514124901, -122.402759939432], [37.725581514124897, -122.402759939432], [37.725591514124901, -122.402759939432], [37.725601514124897, -122.402759939432], [37.7256115141249, -122.402759939432], [37.725621514124896, -122.402759939432], [37.725631514124899, -122.402759939432], [37.725641514124902, -122.402759939432], [37.725651514124898, -122.402759939432], [37.747543334960902, -122.17234039306599], [37.747553334960905, -122.17234039306599], [37.747563334960901, -122.17234039306599], [37.747573334960904, -122.17234039306599], [37.7475833349609, -122.17234039306599], [37.747593334960904, -122.17234039306599], [37.7476033349609, -122.17234039306599], [37.747613334960903, -122.17234039306599], [37.747623334960899, -122.17234039306599], [37.747633334960902, -122.17234039306599], [37.747643334960905, -122.17234039306599], [37.747653334960901, -122.17234039306599], [37.747663334960905, -122.17234039306599], [37.747673334960901, -122.17234039306599], [37.747683334960904, -122.17234039306599], [37.7476933349609, -122.17234039306599], [37.747703334960903, -122.17234039306599], [37.747713334960899, -122.17234039306599], [37.747723334960902, -122.17234039306599], [37.808, -122.41522999999999], [37.808010000000003, -122.41522999999999], [37.808019999999999, -122.41522999999999], [37.808030000000002, -122.41522999999999], [37.808039999999998, -122.41522999999999], [37.808050000000001, -122.41522999999999], [37.808059999999998, -122.41522999999999], [37.808070000000001, -122.41522999999999], [37.808079999999997, -122.41522999999999], [37.80809, -122.41522999999999], [37.808100000000003, -122.41522999999999], [37.808109999999999, -122.41522999999999], [37.808120000000002, -122.41522999999999], [37.779761552810697, -122.229777574539], [37.779771552810701, -122.229777574539], [37.779781552810697, -122.229777574539], [37.7797915528107, -122.229777574539], [37.779801552810696, -122.229777574539], [37.779811552810699, -122.229777574539], [37.779821552810695, -122.229777574539], [37.779831552810698, -122.229777574539], [37.7639, -122.46447000000001], [37.763910000000003, -122.46447000000001], [37.763919999999999, -122.46447000000001], [37.763930000000002, -122.46447000000001], [37.763939999999998, -122.46447000000001], [37.763950000000001, -122.46447000000001], [37.763959999999997, -122.46447000000001], [37.76397, -122.46447000000001], [37.7873489077678, -122.409739555912], [37.787358907767803, -122.409739555912], [37.787368907767799, -122.409739555912], [37.787378907767803, -122.409739555912], [37.787388907767799, -122.409739555912], [37.787398907767802, -122.409739555912], [37.787408907767798, -122.409739555912], [37.787418907767801, -122.409739555912], [37.80462, -122.41287], [37.804630000000003, -122.41287], [37.804639999999999, -122.41287], [37.804650000000002, -122.41287], [37.804659999999998, -122.41287], [37.787047000000001, -122.401239], [37.787057000000004, -122.401239], [37.787067, -122.401239], [37.787077000000004, -122.401239], [37.787087, -122.401239], [37.752372600000001, -122.4192638], [37.752382600000004, -122.4192638], [37.7523926, -122.4192638], [37.752402600000003, -122.4192638], [37.7524126, -122.4192638], [37.791293699999997, -122.4010389], [37.7913037, -122.4010389], [37.791313699999996, -122.4010389], [37.7913237, -122.4010389], [37.760272999999998, -122.4208333], [37.760283000000001, -122.4208333], [37.760292999999997, -122.4208333], [37.760303, -122.4208333], [37.79983, -122.40814], [37.799840000000003, -122.40814], [37.799849999999999, -122.40814], [37.799860000000002, -122.40814], [37.716009999999997, -122.44114], [37.71602, -122.44114], [37.716029999999996, -122.44114], [37.768387446964098, -122.41987490636301], [37.768397446964102, -122.41987490636301], [37.768407446964098, -122.41987490636301], [37.799971997737899, -122.216363176703], [37.799981997737902, -122.216363176703], [37.799991997737898, -122.216363176703], [37.788229999999999, -122.40096], [37.788240000000002, -122.40096], [37.760322913527503, -122.507233992219], [37.760332913527506, -122.507233992219], [37.769169400000003, -122.45229], [37.769179400000006, -122.45229], [37.790489200000003, -122.4035873], [37.790499200000006, -122.4035873], [37.801430000000003, -122.42495], [37.801440000000007, -122.42495], [37.7673552796685, -122.429470070463], [37.767365279668503, -122.429470070463], [37.7603950500488, -122.414512634277], [37.760405050048803, -122.414512634277], [37.760573700070402, -122.419309839606], [37.760583700070406, -122.419309839606], [37.790489200000003, -122.4035873], [37.790499200000006, -122.4035873], [37.787233800000003, -122.42019860000001], [37.787243800000006, -122.42019860000001], [37.739420000000003, -122.418243], [37.739430000000006, -122.418243], [37.785493099999997, -122.41301660000001], [37.7855031, -122.41301660000001], [37.769697478971999, -122.44871809120001], [37.752769999999998, -122.50458]]
Out[109]:

In [7]:
import requests
from time import sleep
proxy_list = []

In [8]:
for i in range(60):
    response = requests.get('https://www.proxicity.io/api/v1/984fee31a6c723be2c970db9df3503bf/proxy')
    proxy_list.append(response.json()['ipPort'])
    print response.json()['ip'], response.json()['port']
    sleep(6)


78.153.240.173 3128
66.115.75.196 30293
179.33.5.218 8080
212.47.237.30 9004
91.228.197.252 9406
45.119.124.214 80
209.131.253.152 10200
162.243.240.39 80
94.23.158.49 80
190.72.21.116 8080
89.218.77.218 3128
107.151.136.211 80
41.227.219.202 80
174.129.110.206 80
46.52.164.158 9999
138.122.100.44 8088
187.60.40.113 8080
189.29.118.28 8080
85.229.146.245 34017
213.169.83.105 80
191.102.87.242 3128
177.124.100.24 1080
78.96.59.226 8080
187.161.26.202 41323
203.66.159.44 3128
66.64.202.66 3128
187.188.196.152 8080
95.37.6.248 3128
52.68.185.169 80
112.175.234.216 8088
80.255.82.138 8080
54.229.50.90 8083
50.31.152.124 28910
119.93.82.148 80
149.56.172.165 11346
201.22.213.7 8080
54.193.92.18 8083
13.79.159.2 80
92.51.77.126 1080
187.161.214.19 28082
70.189.143.246 3128
124.120.219.167 8888
183.91.33.76 89
190.121.18.220 8080
45.32.52.205 3128
200.21.21.157 8080
123.52.74.96 1080
118.232.17.74 8998
200.108.143.123 3128
138.122.100.44 8088
128.199.74.125 3128
110.78.150.67 8080
186.88.37.219 8080
212.47.236.192 9011
119.82.231.82 8080
97.92.105.234 8080
149.56.172.54 11235
97.92.105.234 8080
124.254.60.70 1080
59.120.185.244 3128

In [4]:



Out[4]:
u'60.191.175.53:3128'

In [ ]: