こうなると困ります…
http://i.joyton.com:2010
この画像を使用すると、同じ結果が得られる場合があります。、およびその他のパラメーターはデフォルトのままです。
def search_img(item, image_name):
try:
f = open(image_name, 'rb')
img = f.read()
print type(img)
except IOError, e:
print 'fail to open %s' % image_name
print e
return None
ts = str(time.time())
m = md5.new('testsearch_by_image' + item)
m.update(ts)
m.update('0123456789')
sign = m.hexdigest()
params = urllib.urlencode( {
'item': item,
'app_key': 'test',
'cmd':'search_by_image',
'sign':sign,
'img_file':img,
'extra':'',
'time_stamp':ts,
})
headers = {'Content-type': 'application/x-www-form-urlencode',
'Accept': 'text/plain'}
conn = httplib.HTTPConnection('i.joyton.com', 2010)
conn.request('POST', '', params, headers)
response = conn.getresponse()
print response.status, response.reason
print response.read()
conn.close()
return response.read()
if __name__ == '__main__':
search_img('book', 'f:\\book_001.jpg')
ブラウザではすべてが完全に機能しますが、私のスクリプトはそうではありません。スクリプトが正しい結果を返す場合もあります。他の本を手に入れることもあれば、何も手に入れないこともあります。他の本を取得すると、これらの本は通常、最近他の人によって検索されます。