给你的网站加上站内搜索---Compass入门教程

news/2024/5/20 10:48:29/文章来源:https://blog.csdn.net/jeff06143132/article/details/7953241

Compass(基于Lucene)入门教程

1 序言

2 Compass介绍

3 单独使用Compass

4 spring+hibernate继承compass

4-1 jar包

4-2 配置文件

4-3 源代码

4-4 说明

4-5 测试

5 总结下吧

1 序言

这些天一直在学点新的东西,想给毕业设计添加点含量,长时间的SSH项目也想尝试下新的东西和完善以前的技术,搜索毋容置疑是很重要的。作为javaer,作为apache的顶级开源项目lucene应该有所耳闻吧,刚学完lucene,知道了基本使用,学的程度应该到可以使用的地步,但不的不说lucene官方给的文档例子不是很给力的,还好互联网上资料比较丰富!在搜索lucene的过程中,知道了基于lucene的compass和lucene-nutch。lucene可以对给定内容加上索引搜索,但比如搜索本地数据库和web网页,你需要把数据给拿出来索引再搜索,所以你就想可不可以直接搜索数据库,以数据库内容作为索引,并且伴随着数据库的CRUD,索引也会更新,compass出现了,compass作为站内搜索那是相当的方便的,并且官方提供了spring和hibernate的支持,更是方便了。Lucene-nutch是基于lucene搜索web页面的,如果有必要我在分享下lucene、lecene-nutch的学习经验,快速入门,其他的可以交给文档和谷歌了。

不得不提下,compass09年貌似就不更新了,网上说只支持lucene3.0以下版本,蛮好的项目不知道为什么不更新了,试了下3.0以后的分词器是不能使用了,我中文使用JE-Analyzer.jar。我使用的环境:

Spring3.1.0+Hibernate3.6.6+Compass2.2.0。

2 Compass介绍

Compass是一个强大的,事务的,高性能的对象/搜索引擎映射(OSEM:object/search engine mapping)与一个Java持久层框架.Compass包括: 

* 搜索引擎抽象层(使用Lucene搜索引荐),

* OSEM (Object/Search Engine Mapping) 支持,

* 事务管理,

* 类似于Google的简单关键字查询语言,

* 可扩展与模块化的框架,

* 简单的API.

官方网站:谷歌

3 单独使用Compass

Compass可以不继承到hibernate和spring中的,这个是从网上摘录的,直接上代码:

wps_clip_image-6849wps_clip_image-20611wps_clip_image-27320

 

@Searchable

public class Book {

private String id;//编号

private String title;//标题

private String author;//作者

private float price;//价格

public Book() {

}

public Book(String id, String title, String author, float price) {

super();

this.id = id;

this.title = title;

this.author = author;

this.price = price;

}

@SearchableId

public String getId() {

return id;

}

@SearchableProperty(boost = 2.0F, index = Index.TOKENIZED, store = Store.YES)

public String getTitle() {

return title;

}

@SearchableProperty(index = Index.TOKENIZED, store = Store.YES)

public String getAuthor() {

return author;

}

@SearchableProperty(index = Index.NO, store = Store.YES)

public float getPrice() {

return price;

}

public void setId(String id) {

this.id = id;

}

public void setTitle(String title) {

this.title = title;

}

public void setAuthor(String author) {

this.author = author;

}

public void setPrice(float price) {

this.price = price;

}

@Override

public String toString() {

return "[" + id + "] " + title + " - " + author + " $ " + price;

}

}

public class Searcher {

protected Compass compass;

public Searcher() {

}

public Searcher(String path) {

compass = new CompassAnnotationsConfiguration()//

.setConnection(path).addClass(Book.class)//

.setSetting("compass.engine.highlighter.default.formatter.simple.pre", "<font color='red'>")//

.setSetting("compass.engine.highlighter.default.formatter.simple.post", "</font>")//

.buildCompass();//

Runtime.getRuntime().addShutdownHook(new Thread() {

public void run() {

compass.close();

}

});

 

}

/**

* 新建索引

* @param book

*/

public void index(Book book) {

CompassSession session = null;

CompassTransaction tx = null;

try {

session = compass.openSession();

tx = session.beginTransaction();

session.create(book);

tx.commit();

} catch (RuntimeException e) {

if (tx != null)

tx.rollback();

throw e;

} finally {

if (session != null) {

session.close();

}

}

}

/**

* 删除索引

* @param book

*/

public void unIndex(Book book) {

CompassSession session = null;

CompassTransaction tx = null;

try {

session = compass.openSession();

tx = session.beginTransaction();

session.delete(book);

tx.commit();

} catch (RuntimeException e) {

tx.rollback();

throw e;

} finally {

if (session != null) {

session.close();

}

}

}

 

/**

* 重建索引

* @param book

*/

public void reIndex(Book book) {

unIndex(book);

index(book);

}

 

/**

* 搜索

* @param queryString

* @return

*/

public List<Book> search(String queryString) {

CompassSession session = null;

CompassTransaction tx = null;

try {

session = compass.openSession();

tx = session.beginTransaction();

CompassHits hits = session.find(queryString);

int n = hits.length();

if (0 == n) {

return Collections.emptyList();

}

List<Book> books = new ArrayList<Book>();

for (int i = 0; i < n; i++) {

books.add((Book) hits.data(i));

}

hits.close();

tx.commit();

return books;

} catch (RuntimeException e) {

tx.rollback();

throw e;

} finally {

if (session != null) {

session.close();

}

}

}

public class Main {

static List<Book> db = new ArrayList<Book>();

static Searcher searcher = new Searcher("index");

 

public static void main(String[] args) {

add(new Book(UUID.randomUUID().toString(), "Thinking in Java", "Bruce", 109.0f));

add(new Book(UUID.randomUUID().toString(), "Effective Java", "Joshua", 12.4f));

add(new Book(UUID.randomUUID().toString(), "Java Thread Programing", "Paul", 25.8f));

long begin = System.currentTimeMillis();

int count = 30;

for(int i=1; i<count; i++) {

if(i%10 == 0) {

long end = System.currentTimeMillis();

System.err.println(String.format("当时[%d]条,剩[%d]条,已用时间[%ds],估计时间[%ds].", i,count-i,(end-begin)/1000, (int)((count-i)*((end-begin)/(i*1000.0))) ));

}

String uuid = new Date().toString();

add(new Book(uuid, uuid.substring(0, uuid.length()/2), uuid.substring(uuid.length()/2), (float)Math.random()*100));

}

int n;

do {

n = displaySelection();

switch (n) {

case 1:

listBooks();

break;

case 2:

addBook();

break;

case 3:

deleteBook();

break;

case 4:

searchBook();

break;

case 5:

return;

}

} while (n != 0);

}

 

static int displaySelection() {

System.out.println("\n==select==");

System.out.println("1. List all books");

System.out.println("2. Add book");

System.out.println("3. Delete book");

System.out.println("4. Search book");

System.out.println("5. Exit");

int n = readKey();

if (n >= 1 && n <= 5)

return n;

return 0;

}

 

/**

* 增加一本书到数据库和索引中

*

* @param book

*/

private static void add(Book book) {

db.add(book);

searcher.index(book);

}

 

/**

* 打印出数据库中的所有书籍列表

*/

public static void listBooks() {

System.out.println("==Database==");

int n = 1;

for (Book book : db) {

System.out.println(n + ")" + book);

n++;

}

}

 

/**

* 根据用户录入,增加一本书到数据库和索引中

*/

public static void addBook() {

String title = readLine(" Title: ");

String author = readLine(" Author: ");

String price = readLine(" Price: ");

Book book = new Book(UUID.randomUUID().toString(), title, author, Float.valueOf(price));

add(book);

}

 

/**

* 删除一本书,同时删除数据库,索引库中的

*/

public static void deleteBook() {

listBooks();

System.out.println("Book index: ");

int n = readKey();

Book book = db.remove(n - 1);

searcher.unIndex(book);

}

 

/**

* 根据输入的关键字搜索书籍

*/

public static void searchBook() {

String queryString = readLine(" Enter keyword: ");

List<Book> books = searcher.search(queryString);

System.out.println(" ====search results:" + books.size() + "====");

for (Book book : books) {

System.out.println(book);

}

}

 

public static int readKey() {

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

try {

int n = reader.read();

n = Integer.parseInt(Character.toString((char) n));

return n;

} catch (Exception e) {

throw new RuntimeException();

}

}

 

public static String readLine(String propt) {

System.out.println(propt);

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

try {

return reader.readLine();

} catch (Exception e) {

throw new RuntimeException();

}

}

}

wps_clip_image-5530

这种方法向数据库插入数据和加索引速度很慢,下面方法可以提高,注意这上面没设置分词器,所以使用默认的,如果是中文的话会分隔为一个一个的。

4 spring+hibernate继承compass

4-1 jar包

wps_clip_image-25759wps_clip_image-5116wps_clip_image-20051wps_clip_image-11513wps_clip_image-29500wps_clip_image-6212

4-2 配置文件

wps_clip_image-9831

Beans.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="http://www.springframework.org/schema/beans

         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

         http://www.springframework.org/schema/context

         http://www.springframework.org/schema/context/spring-context-3.0.xsd

         http://www.springframework.org/schema/tx

      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

         http://www.springframework.org/schema/aop

         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<context:annotation-config />

<context:component-scan base-package="com.syx.compass"></context:component-scan>

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>

 

<import resource="hibernate-beans.xml"/>

<import resource="compass-beans.xml"/>

</beans>

compass-beans.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="...">

 

<!--compass主配置 -->

<bean id="compass" class="org.compass.spring.LocalCompassBean">

<property name="compassSettings">

<props>

<prop key="compass.engine.connection">file://compass</prop><!-- 数据索引存储位置 -->

<prop key="compass.transaction.factory">

org.compass.spring.transaction.SpringSyncTransactionFactory</prop>

<prop key="compass.engine.analyzer.default.type">

jeasy.analysis.MMAnalyzer</prop><!--定义分词器-->  

<prop key="compass.engine.highlighter.default.formatter.simple.pre">

<![CDATA[<font color="red"><b>]]></prop>

<prop key="compass.engine.highlighter.default.formatter.simple.post">

<![CDATA[</b></font>]]></prop>

</props>

</property>

<property name="transactionManager">

<ref bean="txManager" />

</property>

<property name="compassConfiguration"  ref="annotationConfiguration" /> 

<property name="classMappings"> 

            <list> 

                <value>com.syx.compass.test1.Article</value> 

            </list> 

        </property> 

</bean>

<bean id="annotationConfiguration"

class="org.compass.annotations.config.CompassAnnotationsConfiguration">

</bean>

<bean id="compassTemplate" class="org.compass.core.CompassTemplate">

<property name="compass" ref="compass" />

</bean>

<!-- 同步更新索引, 数据库中的数据变化后同步更新索引 -->

<bean id="hibernateGps" class="org.compass.gps.impl.SingleCompassGps"

init-method="start" destroy-method="stop">

<property name="compass">

<ref bean="compass" />

</property>

<property name="gpsDevices">

<list>

<ref bean="hibernateGpsDevice"/>

</list>

</property>

</bean>

<!--hibernate驱动 链接compass和hibernate -->

<bean id="hibernateGpsDevice"

class="org.compass.spring.device.hibernate.dep.SpringHibernate3GpsDevice">

<property name="name">

<value>hibernateDevice</value>

</property>

<property name="sessionFactory">

<ref bean="sessionFactory" />

</property>

<property name="mirrorDataChanges"> 

            <value>true</value> 

        </property> 

</bean>

<!-- 定时重建索引(利用quartz)或随Spring ApplicationContext启动而重建索引 --> 

    <bean id="compassIndexBuilder" 

        class="com.syx.compass.test1.CompassIndexBuilder" 

        lazy-init="false"> 

        <property name="compassGps" ref="hibernateGps" /> 

        <property name="buildIndex" value="false" /> 

        <property name="lazyTime" value="1" /> 

    </bean> 

     <!-- 搜索引擎服务类 --> 

    <bean id="searchService"  class=" com.syx.compass.test1.SearchServiceBean"> 

        <property name="compassTemplate"> 

            <ref bean="compassTemplate" /> 

        </property> 

    </bean> 

</beans>

hibernate-beans.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="...">

 

<!-- DataSource -->

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

<property name="driverClass" value="${jdbc.driverClassName}" />

<property name="jdbcUrl" value="${jdbc.url}" />

<property name="user" value="${jdbc.username}" />

<property name="password" value="${jdbc.password}" />

<property name="autoCommitOnClose" value="true" />

<property name="checkoutTimeout" value="${cpool.checkoutTimeout}" />

<property name="initialPoolSize" value="${cpool.minPoolSize}" />

<property name="minPoolSize" value="${cpool.minPoolSize}" />

<property name="maxPoolSize" value="${cpool.maxPoolSize}" />

<property name="maxIdleTime" value="${cpool.maxIdleTime}" />

<property name="acquireIncrement" value="${cpool.acquireIncrement}" />

<!-- <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/> -->

</bean>

<bean

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="locations">

<value>classpath:jdbc.properties</value>

</property>

</bean>

<!-- SessionFacotory -->

<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

<property name="dataSource" ref="dataSource" />

<property name="annotatedClasses">

<list>

<value>com.syx.compass.model.Article</value>

<value>com.syx.compass.model.Author</value>

<value>com.syx.compass.test1.Article</value>

</list>

</property>

<property name="hibernateProperties">

<props>

<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>

<prop key="hibernate.current_session_context_class">thread</prop>

<prop key="javax.persistence.validation.mode">none</prop>

<prop key="hibernate.show_sql">true</prop>

<prop key="hibernate.format_sql">false</prop>

<prop key="hibernate.hbm2ddl.auto">update</prop>

</props>

</property>

</bean>

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">

<property name="sessionFactory" ref="sessionFactory"></property>

</bean>

<bean id="txManager"

class="org.springframework.orm.hibernate3.HibernateTransactionManager">

<property name="sessionFactory" ref="sessionFactory" />

</bean>

</beans>

jdbc.properties

jdbc.driverClassName=com.mysql.jdbc.Driver

jdbc.hostname=localhost

jdbc.url=jdbc:mysql://localhost:3306/compass

jdbc.username=root

jdbc.password=root

cpool.checkoutTimeout=5000

cpool.minPoolSize=1

cpool.maxPoolSize=4

cpool.maxIdleTime=25200

cpool.maxIdleTimeExcessConnections=1800

cpool.acquireIncrement=5

log4j.properties

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.Target=System.out

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.rootLogger=error, stdout

4-3 源代码

wps_clip_image-5691

@Searchable(alias = "article")

@Entity(name="_article")

public class Article {

private Long ID; // 标识ID

private String content; // 正文

private String title; // 文章标题

private Date createTime; // 创建时间

public Article(){}

public Article(Long iD, String content, String title, Date createTime) {

ID = iD;

this.content = content;

this.title = title;

this.createTime = createTime;

}

public String toString() {

return String.format("%d,%s,%s,%s", ID, title, content, createTime.toString());

}

@SearchableId

@Id

@GeneratedValue

public Long getID() {

return ID;

}

public void setID(Long id) {

ID = id;

}

@SearchableProperty(index = Index.TOKENIZED, store = Store.YES)

public String getContent() {

return content;

}

public void setContent(String content) {

this.content = content;

}

@SearchableProperty(index = Index.TOKENIZED, store = Store.YES)

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

@SearchableProperty(index = Index.TOKENIZED, store = Store.YES)

public Date getCreateTime() {

return createTime;

}

public void setCreateTime(Date createTime) {

this.createTime = createTime;

}

}

public class CompassIndexBuilder implements InitializingBean {   

   

    // 是否需要建立索引,可被设置为false使本Builder失效.    

    private boolean buildIndex = false;    

   

    // 索引操作线程延时启动的时间,单位为秒    

    private int lazyTime = 10;    

   

    // Compass封装    

    private CompassGps compassGps;    

   

    // 索引线程    

    private Thread indexThread = new Thread() {    

   

        @Override   

        public void run() {    

            try {    

                Thread.sleep(lazyTime * 1000);    

                System.out.println("begin compass index...");    

                long beginTime = System.currentTimeMillis();    

                // 重建索引.    

                // 如果compass实体中定义的索引文件已存在,索引过程中会建立临时索引,    

                // 索引完成后再进行覆盖.    

                compassGps.index();    

                long costTime = System.currentTimeMillis() - beginTime;    

                System.out.println("compss index finished.");    

                System.out.println("costed " + costTime + " milliseconds");    

            } catch (InterruptedException e) {    

                e.printStackTrace();    

            }    

        }    

    };    

   

    /**  

     * 实现<code>InitializingBean</code>接口,在完成注入后调用启动索引线程.

     */   

    public void afterPropertiesSet() throws Exception {    

        if (buildIndex) {    

            indexThread.setDaemon(true);    

            indexThread.setName("Compass Indexer");    

            indexThread.start();    

        }    

    }    

   

    public void setBuildIndex(boolean buildIndex) {    

        this.buildIndex = buildIndex;    

    }    

   

    public void setLazyTime(int lazyTime) {    

        this.lazyTime = lazyTime;    

    }    

   

    public void setCompassGps(CompassGps compassGps) {    

        this.compassGps = compassGps;    

    }    

}  

public class SearchServiceBean {

 

private CompassTemplate compassTemplate;

 

/** 索引查询 * */

public Map find(final String keywords, final String type, final int start, final int end) {

return compassTemplate.execute(new CompassCallback<Map>() {

 

public Map doInCompass(CompassSession session) throws CompassException {

List result = new ArrayList();

int totalSize = 0;

Map container = new HashMap();

CompassQuery query = session.queryBuilder().queryString(keywords).toQuery();

CompassHits hits = query.setAliases(type).hits();

totalSize = hits.length();

container.put("size", totalSize);

int max = 0;

if (end < hits.length()) {

max = end;

} else {

max = hits.length();

}

 

if (type.equals("article")) {

for (int i = start; i < max; i++) {

Article article = (Article) hits.data(i);

String title = hits.highlighter(i).fragment("title");

if (title != null) {

article.setTitle(title);

}

String content = hits.highlighter(i).setTextTokenizer(CompassHighlighter.TextTokenizer.AUTO).fragment("content");

if (content != null) {

 

article.setContent(content);

}

result.add(article);

}

}

container.put("result", result);

return container;

}

});

}

 

public CompassTemplate getCompassTemplate() {

return compassTemplate;

}

 

public void setCompassTemplate(CompassTemplate compassTemplate) {

this.compassTemplate = compassTemplate;

}

}

public class MainTest {

public static ClassPathXmlApplicationContext applicationContext;

private static HibernateTemplate hibernateTemplate;

@BeforeClass

public static void init() {

System.out.println("sprint init...");

applicationContext = new ClassPathXmlApplicationContext("beans.xml");

hibernateTemplate = applicationContext.getBean(HibernateTemplate.class);

System.out.println("sprint ok");

}

 

@Test

public void addData() {

System.out.println("addDate");

//把compass-beans.xml 中 bean id="compassIndexBuilder"

//buildIndex=true lazyTime=1

//会自动的根据数据库中的数据重新建立索引

try {

Thread.sleep(10000000);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

@Test

public void search() {

String keyword = "全文搜索引擎";

SearchServiceBean ssb = applicationContext.getBean(SearchServiceBean.class);

Map map = ssb.find(keyword, "article", 0, 100);//第一次搜索加载词库

long begin = System.currentTimeMillis();

map = ssb.find(keyword, "article", 0, 100);//第二次才是搜索用时

long end = System.currentTimeMillis();

System.out.println(String.format(

"搜索:[%s],耗时(ms):%d,记录数:%d", keyword, end-begin, map.get("size")));

List<Article> list = (List<Article>) map.get("result");

for(Article article : list) {

System.out.println(article);

}

}

4-4 说明

compass-beans.xml中可以设置建立索引的目录和分词器,测试的时候我们使用数据库添加数据,启动的建立索引,测试速度。

4-5 测试

使用mysql,写了一个添加数据的函数:

DELIMITER $$

CREATE

    FUNCTION `compass`.`addDateSyx`(num int(8))

    RETURNS varchar(32)

    BEGIN

declare i int(8);

set i = 0;

while ( i < num) DO

insert into _article (title,content, createTime) values (i, num-i, now());

set i = i + 1;

end while;

return "OK";

    END$$

DELIMITER ;

4-5-1 10000条重复的中文数据测试

数据库函数的时候修改下insert:

insert into _article (title,content, createTime) values ('用compass实现站内全文搜索引擎(一)', 'Compass是一个强大的,事务的,高性能的对象/搜索引擎映射(OSEM:object/search engine mapping)与一个Java持久层框架.Compass包括: 

* 搜索引擎抽象层(使用Lucene搜索引荐),

* OSEM (Object/Search Engine Mapping) 支持,

* 事务管理,

* 类似于Google的简单关键字查询语言,

* 可扩展与模块化的框架,

* 简单的API.

 

如果你需要做站内搜索引擎,而且项目里用到了hibernate,那用compass是你的最佳选择。 ', now());

插入数据:

select addDateSyx1(10000);//hibernate 中的 hibernate.hbm2ddl.auto=update

wps_clip_image-569wps_clip_image-11587

建立索引:

wps_clip_image-15051

wps_clip_image-4911

wps_clip_image-16445

10000条,8045ms,速度还不错。

索引大小:

wps_clip_image-10964

搜索:

wps_clip_image-6267

的确分词了,如果使用默认的分词,中文会每个中文分一个,速度比较快,如果使用JE-Anaylzer 116ms也是可以接受的。

4-5-2 10w条重复的中文数据测试

插入数据:

wps_clip_image-32560

Mysql 10w大约12s左右。

建立索引:

wps_clip_image-21575

wps_clip_image-12492索引大小和我想象的差不多,就是时间比我像的长多了,但我不想在试了。

搜索:

wps_clip_image-24973

10w的是数据,243ms还是很不错的,看来只要索引建好,搜索还是很方便的。

5 总结下吧

Compass用起来还是挺顺手的,应该基本需求可以满足的,不知道蛮好的项目怎么就不更新了,不然hibernate search就不会有的。

因为compass的不更新,所以lucene3.0以后的特性就不能用了,蛮可以的,虽然compass可以自动建索引(当然也可以手动CRUD),但如果封装下lucene来完成compass应该可以得到比较好的实现,期待同学们出手了。

 

参考文章:

compass实现站内全文搜索引擎(一)

再谈compass:集成站内搜索

compass快速给你的网站添加搜索功能

ITEYE上一篇也不错,不小心页面关了...

作者:syxChina
出处:http://syxchina.cnblogs.com、 http://hi.baidu.com/syxcs123
本文版权归作者、博客园和百度空间共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则作者会诅咒你的。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_825242.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

想学习建个网站?WAMP Server助你在Windows上快速搭建PHP集成环境

我想只要爬过几天网的同学都会知道PHP吧&#xff0c;异次元的新版本就是基于PHP的WordPress程序制造出来的&#xff0c;还有国内绝大部分论坛都是PHP的哦。据我所知很多同学都想要试着学习一下PHP&#xff0c;无奈要在Windows下安装搭建好一个PHP环境来学习对于菜鸟同学来说繁琐…

计算机组成原理移位图,逻辑运算和移位指令-计算机组成原理与汇编语言-电子发烧友网站...

3.4.1 逻辑运算和移位指令 1.逻辑运算指令(1)NOT OPRD该指令对操作数进行求反操作&#xff0c;然后将结果送回。操作数可以是寄存器或贮器的内容。该指令对标志位不产生影响。例如&#xff1a; NOT AL(2)AND指令该指令对两个操作数进行按位相“与”的逻辑运算。即只有参加相与的…

IE浏览器中用Firebug调试网站的方法

对于大部分做前端设计者而言应该都使用过Firefox浏览器下一款调试网站的扩展插件firebug吧&#xff0c;功能非常的强大&#xff0c;对于我们找出网页兼容性的问题非常的有效。不过对于很多不喜欢使用Firefox浏览器的开发者而言&#xff0c;那么IE浏览器有没有类似的插件呢&…

那些香喷喷的网站

1、蓝奏云网盘&#xff1a;为用户而变革&#xff0c;越简单越好&#xff0c;越快越好 &#xff01; https://pc.woozooo.com/ 网盘工具&#xff0c;无限制的储存空间。最重要的是下载速度毫无限制&#xff0c;你的网速有多快下载速度就有多快&#xff01; 2、docsmall&#xf…

查看php网站瓶颈,使用XHProf查找PHP性能瓶颈

XHProf是facebook 开发的一个测试php性能的扩展&#xff0c;本文记录了在PHP应用中使用XHProf对PHP进行性能优化&#xff0c;查找性能瓶颈的方法。安装Xhprof扩展$ wget http://pecl.php.net/get/xhprof-0.9.4.tgz$ tar -zxvf xhprof-0.9.4.tgz$ cd xhprof-0.9.4$ cd extension…

Linux康乐备份,Kangle(康乐)ep控制面板备份网站数据和恢复的教程

【原创版权所有】其他拓展文章&#xff1a;强烈推荐&#xff01;如果大家希望自动备份并异地保存数据&#xff0c;请访问KOS工具箱 – Kangle EP云备份&#xff1a;KOS云备份&#xff0c;是KOS工具箱推出的第一款付费服务。它可以帮助您每日自动备份Kangle EP所有主机数据。并且…

CSU前端网站 +登陆系统

实现CSU网站主页&#xff0c;并设计实现一个简单全栈登陆系统 实现要求短信验证码实现&#xff1a;臻子云关键功能解析运行结果实现要求 1&#xff09;前端页面的基本布局 布局类似于学校门户顶部需有 LOGO 栏目&#xff1b;提供轮播图&#xff1b;提供账号密码登录方式&…

Linux中搭建静态网站(练习题)

在rhel8的系统上搭建网站&#xff1a;该网站ip地址主机位为11&#xff0c;设置documentroot为/www/你的名字拼音的缩写&#xff0c;网页内容为&#xff1a;my name is… 做题思路&#xff1a; #面对这类的题目&#xff0c;确定好做题思路&#xff1a; #配置题目要求的IP地址关…

搭建https的静态网站

搭建一个基于https://www.zuoye.com访问的web网站&#xff0c;网站首页在/www/https/&#xff0c;内容为exercise。 思路&#xff1a; #思路&#xff1a;准备好https所需要的东西关闭防火墙及SElinux创建目录编写网页内容编写配置文件https相关的东西&#xff1a; [rootloca…

网站架构方案全解析

1、HTML静态化其实大家都知道&#xff0c;效率最高、消耗最小的就是纯静态化的html页面&#xff0c;所以我们尽可能使我们的网站上的页面采用静态页面来实现&#xff0c;这个最简单的方法其实也是最有效的方法。但是对于大量内容并且频繁更新的网站&#xff0c;我们无法全部手动…

[au3]下载css文件里的图片,保存别人的网站时有用。

;by onepc 153785587 #NoTrayIcon#Region ;**** 参数创建于 ACNWrapper_GUI ****#AutoIt3Wrapper_iconC:\windows\system32\SHELL32.dll|-123#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****#include <INet.au3>#include <ButtonConstants.au3>#include <Edit…

老鸟传经:做网站的实用建议

做网站现在似乎是每个企业或团队都必做的一项工作了——不管你所在的行业是不是和互联网相关。我平均每周都会接到一两个朋友的电话问&#xff1a;我们要做一个网站&#xff0c;该用什么技术&#xff0c;PHP、Java还是.NET&#xff1f;我们该从哪里请开发人员&#xff1f;我们现…

可以判断用户打开页面次数吗?_SEO搜索优化,你可以不做外链吗?

自从2015年谷歌建立了Rainbrain&#xff0c;利用机器学习对内容分析与判断以后&#xff0c;很多SEO专家就开始讨论一个问题&#xff0c;SEO关键词排名&#xff0c;我们是不是可以不需要发布链接了&#xff0c;虽然百度也在一度强调&#xff1a;我们将逐渐摒弃技术排名的方法&am…

python抓取网站图片_实例详解Python实现简单网页图片抓取

本文主要介绍了Python实现简单网页图片抓取完整代码实例&#xff0c;具有一定借鉴价值&#xff0c;需要的朋友可以参考下。 利用python抓取网络图片的步骤是&#xff1a; 1、根据给定的网址获取网页源代码 2、利用正则表达式把源代码中的图片地址过滤出来 3、根据过滤出来的图片…

大表多表关联查总数如何优化_咻咻SEO:网站上线前检查哪些内容,如何处理

前期准备工作&#xff1a;已完成站内优化可参考相关文章&#xff1a;一休&#xff1a;咻咻SEO&#xff1a;当网站收录不好&#xff0c;或兼职网站优化&#xff0c;开始优化前如何评测网站&#xff1f;​zhuanlan.zhihu.com网站上线前URL结构怎样优化&#xff1f;什么样的结构是…

用一朵云重建软件开发者的声望——讲述iTechTag网站的故事

&#xff08;本文发表于《程序员》2007年12期&#xff09; &#xff08;本文发表之后&#xff0c;iTechTag又有了较大的变化&#xff0c;请看 http://www.itechtag.com/feeds/46/blogs/92 &#xff09; 用一朵云重建软件开发者的声望 ——讲述iTechTag网站的故事 在接受In…

VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程

开篇语&#xff1a;最近在弄ocx控件发布到asp.net网站上使用&#xff0c;就是用户在使用过程中&#xff0c;自动下载安装ocx控件。&#xff08;此文章也是总结了网上好多人写的文章&#xff0c;我只是汇总一下&#xff0c;加上部分自己的东西&#xff0c;在这里感谢所有在网上发…

wp.qq.com set.html,WordPress网站设置第三方软件登录

WordPress网站当需要用户方便登录时&#xff0c;那么使用QQ、微信、微博这类第三方的信用软件登录不仅便捷也安全&#xff0c;那么该怎样为WordPress网站设置 第三方软件登录的方法呢&#xff1f;以下为具体设置内容&#xff1a;要想在互联网上登录&#xff0c;必须取得唯一id&…

大型网站架构阅读(一)架构演变

大型网站系统特点&#xff1a; 高并发&#xff0c;大流量 高可用&#xff0c;海量数据 用户分布式广泛&#xff0c;网络情况复杂&#xff0c;安全环境恶劣&#xff0c;需求快速变更&#xff0c;发布频繁&#xff0c;渐进式发展。 大型网站演变过程&#xff1a; 大型网站是从小网…

大型网站架构阅读(二)架构模式

1.网站架构模式简介&#xff1a; 随着网站架构的逐渐演变&#xff0c;在其为了解决高并发访问&#xff0c;海量数据处理&#xff0c;高可靠运行等问题&#xff0c;大型互联网公司提出了很多解决方案&#xff0c;这些解决方案逐渐形成了大型网站架构模式。 2.分类&#xff1a; …