import requests
#Search 1
solrResp = requests.get('http://mysolr.com/solr/statedecoded/search?q=law')
for doc in solrResp.json()['response']['docs']:
print doc['catch_line']
#Search 2
solrResp = requests.get('http://mysolr.com/solr/statedecoded/search?q=shoplifting')
for doc in solrResp.json()['response']['docs']:
print doc['catch_line']
import requests
from gevent import monkey
import gevent
monkey.patch_all()
class Searcher(object):
""" Simple wrapper for doing a search and collecting the
results """
def __init__(self, searchUrl):
self.searchUrl = searchUrl
def search(self):
solrResp = requests.get(self.searchUrl)
self.docs = solrResp.json()['response']['docs']
def searchMultiple(urls):
""" Use gevent to execute the passed in urls;
dump the results"""
searchers = [Searcher(url) for url in urls]
# Gather a handle for each task
handles = []
for searcher in searchers:
handles.append(gevent.spawn(searcher.search))
# Block until all work is done
gevent.joinall(handles)
# Dump the results
for searcher in searchers:
print "Search Results for %s" % searcher.searchUrl
for doc in searcher.docs:
print doc['catch_line']
searchUrls = ['http://mysolr.com/solr/statedecoded/search?q=law',
'http://mysolr.com/solr/statedecoded/search?q=shoplifting']
# Gather a handle for each task handles = [] for searcher in searchers: handles.append(gevent.spawn(searcher.search)) # Block until all work is done gevent.joinall(handles)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有