def spider_closed(self, spider):
"""Handle the spider_closed event to save the map"""
# create the special marker for all the ads without geocode
print "found %d items without geocode" % (len(self.no_geocode))
if len(self.no_geocode) > 0:
html = ""
for x in self.no_geocode:
html += "<a href=%s target=_blank>%s</a> : %s<br>" % (x["url"], x["title"], x["price"])
iframe = folium.element.IFrame(html=html, width=500, height=100)
popup = folium.Popup(iframe, max_width=500)
folium.Marker(MAP_LATLNG,
popup=popup,
icon=folium.Icon()).add_to(self.m_map)
print "found %d new items" % (self.new_items)
pickle.dump(self.m_list, open(DATABASE, 'wb'))
self.m_map.save('map.html')
评论列表
文章目录