Code Monkey home page Code Monkey logo

i-book.in_archive's Introduction

i-book.in_Archive

我不能够授人以鱼,但是我可以授人以渔。这里是 i-book.in 搜索引擎的归档项目,我不会更新和继续维护这个搜索引擎,你可以拿它去做任何你想做的事情。

另:使用此代码产生的任何风险与利益均与我无关。 切记!请不要在你的网站上留下任何关于 i-book.in 的信息。


注意!这只是个框架,没有任何数据,不要想着自己搭建一下,就能够搜索到书了。

下面是一个简单的安装教程,我尽可能写的明白了,如有不清楚的,可以到我的tg群组讨论 : https://t.me/SaltyLeo_blog

基本需求

python3、docker

搭建说明

首先安装一系列必须的插件与更新。

apt install python3-pip
pip3 install flask
pip3 install elasticsearch
pip3 install flask_bootstrap

安装 docker版es

curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh && docker pull elasticsearch:6.7.0

cd  /
mkdir -p mnt/elasticsearch
cd  mnt/elasticsearch
mkdir config
mkdir master
mkdir slave
chmod 777 master
chmod 777 slave
cd config
touch master.yml
touch slave.yml
nano master.yml

将下列参数粘贴到打开的nano编辑器内。

cluster.name: elasticsearch-cluster
node.name: master
network.bind_host: 0.0.0.0
network.publish_host: 127.0.0.1
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300","127.0.0.1:9301"]

修改线程限制

nano /etc/sysctl.conf
#添加这个
vm.max_map_count=262144 
#保存后执行这个命令
sysctl -p

初始化 es搜索引擎

docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -v /mnt/elasticsearch/config/master.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mnt/elasticsearch/master:/usr/share/elasticsearch/data --name es-master elasticsearch:6.7.0

下载源码

wget https://github.com/SaltyLeo/i-book.in_Archive/raw/master/i-book.in.tar.gz && tar -zxvf i-book.in.tar.gz && cd web

#墙内无法访问GitHub使用下面这个
wget https://ibookin-1252237247.cos.ap-shanghai.myqcloud.com/i-book.in.tar.gz && tar -zxvf i-book.in.tar.gz && cd web

将索引数据导入到ES

python3 add2es.py

可能会弹出以下错误,但请忽略即可。

/usr/local/lib/python3.6/dist-packages/elasticsearch/connection/base.py:177: ElasticsearchDeprecationWarning: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
  warnings.warn(message, category=ElasticsearchDeprecationWarning)

运行demo

python3 web.py

这时候打开你的服务器IP+端口7743即可打开搜索引擎,例:127.0.0.1:7743,如下图:

image.png

一些提示

网站的logo以及其他的icon都写死在css中,我改不来,所以没怎么调整,改过的几个png很显而易见。

网站索引文件按照test.json格式导入即可,请注意,add2es这个脚本每次都会清空es索引后再执行导入。

各种链接按需修改,请注意web.py改了return的话,前端html文件也需要改,否则flask会报错。

偶尔docker会卡死使用这个命令重启所有docker docker restart $(docker ps -a | awk '{ print $1}' | tail -n +2)

其他的自己摸索吧,对于前端我也不是非常的熟练,

i-book.in_archive's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

i-book.in_archive's Issues

删除失败

执行 python3 add2es.py 命令报错,内容如下:
` 删除失败
1
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connection.py", line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 246, in perform_request
method, url, body, retries=Retry(False), headers=request_headers, **kw
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/util/retry.py", line 506, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 706, in urlopen
chunked=chunked,
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connection.py", line 234, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/python3/lib/python3.7/http/client.py", line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/python3/lib/python3.7/http/client.py", line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/python3/lib/python3.7/http/client.py", line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/python3/lib/python3.7/http/client.py", line 1032, in _send_output
self.send(msg)
File "/usr/local/python3/lib/python3.7/http/client.py", line 972, in send
self.connect()
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connection.py", line 200, in connect
conn = self._new_conn()
File "/usr/local/python3/lib/python3.7/site-packages/urllib3/connection.py", line 182, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f68bb133090>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "add2es.py", line 12, in
es.index(index="es",body=line)
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped
return func(*args, params=params, headers=headers, **kwargs)
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/client/init.py", line 403, in index
body=body,
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/transport.py", line 390, in perform_request
raise e
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/transport.py", line 365, in perform_request
timeout=timeout,
File "/usr/local/python3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 258, in perform_request
raise ConnectionError("N/A", str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f68bb133090>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f68bb133090>: Failed to establish a new connection: [Errno 111] Connection refused)`

还有个问题,怎么样才能搜到网上的电子书?

配置成功后找不到网页

您好,我是安装在centos虚拟机里面的,配置过程中没有出先其他的错误,和您这个步骤一样,就是最后访问的时候我用主机访问,显示炸不到网页,我输入的虚拟机ip:7743。最后两步的输出如下:
[root@localhost web]# python3 add2es.py
删除失败
1
/usr/local/lib/python3.6/site-packages/elasticsearch/connection/base.py:177: ElasticsearchDeprecationWarning: the default number of shards will change from [5] to [1] in 7.0.0; if you wish to continue using the default of [5] shards, you must manage this on the create index request or with an index template
warnings.warn(message, category=ElasticsearchDeprecationWarning)
2
[root@localhost web]# python3 web.py

  • Serving Flask app "web" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
  • Running on http://0.0.0.0:7743/ (Press CTRL+C to quit)
  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 168-049-036

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.