Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3网络实战爬虫第二版 ElasticSearch一系列问题 #1

Open
RuoCJ opened this issue Jun 10, 2022 · 3 comments
Open

python3网络实战爬虫第二版 ElasticSearch一系列问题 #1

RuoCJ opened this issue Jun 10, 2022 · 3 comments

Comments

@RuoCJ
Copy link

RuoCJ commented Jun 10, 2022

@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,这些问题我没能找到解决办法,所以向您求助。
谢谢!

@Allen0845
Copy link

我也遇到了相同的问题,请问解决了吗

@Germey
Copy link
Member

Germey commented Jul 10, 2022

我感觉可能是版本问题,我的案例是 Elasticsearch 7.0 的,请尝试安装 7.0 版本和对应的 Python eleasticsearch 库

@RuoCJ
Copy link
Author

RuoCJ commented Jul 10, 2022

我感觉可能是版本问题,我的案例是 Elasticsearch 7.0 的,请尝试安装 7.0 版本和对应的 Python eleasticsearch 库

好的 谢谢 我尝试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants