-
Notifications
You must be signed in to change notification settings - Fork 9
Description
@Germey hello,我在您python3网络爬虫开发实战第二版中,在4.7 elasticsearch这一章学习过程中,发现一些问题,可能是因为版本更新的原因,例如:
from elasticsearch import Elasticsearch
es = Elasticsearch()
result = es.indices.create(index='news',ignore=400)
print(result)
上面的会报错:
ValueError: Either 'hosts' or 'cloud_id' must be specified
然后,当我这么写就不报错了
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts='https://localhost:9200/')
result = es.indices.create(index='news',ignore=400)
print(result)
但是,又出现这样的错误:
elastic_transport.TlsError: TLS error caused by: TlsError(TLS error caused by: SSLError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)))
然后,这么修改一下:
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts='https://localhost:9200',verify_certs=False/)
result = es.indices.create(index='news',ignore=400)
print(result)
就会有新的错误:
elasticsearch.AuthenticationException: AuthenticationException(401, 'security_exception', 'missing authentication credentials for REST request [/news]')
我是第一次接触elasticsearch,这些问题我没能找到解决办法,所以向您求助。
谢谢!