Home >Backend Development >PHP Tutorial >Teach you step by step how to do a keyword matching project (search engine)----On the fifth day, teach you how to do it----_PHP Tutorial

Teach you step by step how to do a keyword matching project (search engine)----On the fifth day, teach you how to do it----_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:20944browse

Teach you step by step how to do keyword matching projects (search engines)----The fifth day, teach you how to do----

The fifth day

Every time a week is about to pass, you need to summarize. Boss Yu also warned Xiao Shuaishuai like this. Book your work for next week before the weekend and provide this week’s summary to Boss Yu.

The protagonist is a programmer, and everything revolves around Xiao Shuai Shuai as a guide to carry out this project.

Xiao Shuai Shuai is keen on technology, and his desire for technology is relatively high. His early technology is not very good, but he has many advantages, which will be reflected in subsequent articles.

Yu Laoda Project Director, he is more inclined to cultivate people, so his communication skills are different.

Director Wang, the words you speak have a different momentum. They can bring you closer to each other, encourage you to work hard, and make you willing.

Everyone’s role here is different, and their communication skills are different. Programmers may learn technology here, and project managers may learn communication skills and how to deal with people. and how to develop trustworthy people.

Back to business:

After practicing all night, Xiao Shuaishuai returned to the company listlessly with dark circles under his eyes. He happened to meet Boss Yu and said excitedly: Boss Yu, the one you gave me yesterday PHP Simple HTML DOM Parser, I spent a whole night looking at it and finally figured it out. I will send you the code later to help you see if there are any problems?

Boss Yu looked at Xiao Shuaishuai with dark circles and said: You stayed up late, I will give you a day off today, have a good rest, you will be stronger when you are in good spirits, pay attention to rest next time, don't affect the next day work.

Xiao Shuaishuai also felt that it was not good to work like this, so he said to the boss: Thank you, boss Yu. I will pay attention to it next time. I will send you the code later and then go back to rest.

Boss Yu couldn’t say anything more, so he had to agree: Okay.

HTML of keywords in Taobao:

<span><</span><span>div </span><span>class</span><span>="search-hots"</span><span>><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.1.z5UFkc&amp;q=%B4%F3%C2%EB%C5%AE%D7%B0&amp;refpid=420460_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.1"</span><span>></span>大码女装<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.2.z5UFkc&amp;q=%C5%AE%D1%A9%B7%C4%C9%C0&amp;refpid=420461_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.2"</span><span>></span>雪纺衫<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.3.z5UFkc&amp;q=%C1%AC%D2%C2%C8%B9&amp;refpid=420462_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> class</span><span>="h"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.3"</span><span>></span>连衣裙<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.4.z5UFkc&amp;q=%C5%AE%C1%B9%D0%AC&amp;refpid=420463_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.4"</span><span>></span>女士凉鞋<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.5.z5UFkc&amp;q=%C5%AE%B0%FC&amp;refpid=420464_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.5"</span><span>></span>时尚女包<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.6.z5UFkc&amp;q=%C5%AEt%D0%F4&amp;refpid=420465_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.6"</span><span>></span>女士T恤<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.7.z5UFkc&amp;q=%C4%D0t%D0%F4&amp;refpid=420466_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.7"</span><span>></span>男士T恤<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.8.z5UFkc&amp;q=%B7%C0%C9%B9%D2%C2&amp;refpid=420467_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.8"</span><span>></span>防晒衣<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.9.z5UFkc&amp;q=%C7%E9%C2%C2%D7%B0&amp;refpid=430144_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.9"</span><span>></span>情侣装<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.10.z5UFkc&amp;q=%B6%CC%BF%E3&amp;refpid=430145_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.10"</span><span>></span>短裤<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.11.z5UFkc&amp;q=%D3%BE%D2%C2&amp;refpid=430146_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.11"</span><span>></span>泳衣<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.12.z5UFkc&amp;q=%C4%D0%D0%AC&amp;refpid=430147_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.12"</span><span>></span>新款男鞋<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.13.z5UFkc&amp;q=%C1%B9%CF%AF&amp;refpid=430148_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.13"</span><span>></span>凉席<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.14.z5UFkc&amp;q=%B3%A4%C8%B9&amp;refpid=430149_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.14"</span><span>></span>长裙<span></</span><span>a</span><span>></span> <span><</span><span>a </span><span>href</span><span>="//s.taobao.com/search?spm=1.7274553.1997520241.15.z5UFkc&amp;q=%CD%CF%D0%AC&amp;refpid=430150_1006&amp;source=tbsy&amp;style=grid&amp;tab=all"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.15"</span><span>></span>拖鞋<span></</span><span>a</span><span>></span> 
  <span><</span><span>a </span><span>class</span><span>="more more-with-border"</span><span> href</span><span>="http://top.taobao.com/index.php?spm=1.7274553.1997520241.16.z5UFkc&amp;from=tbsy"</span><span> data-spm-anchor-id</span><span>="1.7274553.1997520241.16"</span><span>></span>更多<span><</span><span>i</span><span>><</span><span>em</span><span>></</span><span>em</span><span>><</span><span>span</span><span>></</span><span>span</span><span>></</span><span>i</span><span>></</span><span>a</span><span>></span>
<span></</span><span>div</span><span>></span>

Xiao Shuai Shuai’s code is as follows:

<?<span>php

</span><span>$curl</span> = <span>new</span><span> ExtendedCurl();
</span><span>$content</span> = <span>$curl</span>->get("http://www.taobao.com"<span>);
</span><span>if</span>(<span>$curl</span>-><span>hasError()){
    </span><span>throw</span> <span>new</span> <span>Exception</span>(<span>$curl</span>->getError(), <span>$curl</span>-><span>getHttpCode());    
}

</span><span>$html</span> = str_get_html(<span>$content</span><span>);
</span><span>foreach</span>(<span>$html</span>->find(".search-hots a[class!=more]") <span>as</span> <span>$ele</span><span>){
    </span><span>$keywords</span>[] = <span>$ele</span>-><span>innertext;
}

</span><span>foreach</span>(<span>$keywords</span> <span>as</span> <span>$keyword</span><span>){
    </span><span>//</span><span>save $keyword to database</span>
    ....<span>
}</span>

After Xiao Shuai Shuai handed in the code, he went back to rest peacefully. When he fell asleep, he had a dream. The content in the dream was not suitable for children, so skip it....

Just like that, Xiao Shuaishuai’s thrilling week has passed...

How do the search terms in Baidu search engine match the promotional keywords?

Currently, Baidu promotion has three matching methods: precise, phrase, and broad. Generally speaking, the golden combination matching method is: broad matching + search term report + negative keywords. In terms of traffic, it's broad>phrase>accurate. You can set it according to your actual situation!

When searching with a search engine, if there are three keywords and you want an exact match, how should you enter them?

If you want an exact match, you need to put quotes around ABC.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/860054.htmlTechArticleTeach you step by step how to do keyword matching projects (search engines)----On the fifth day, teach you how to do- --- On the fifth day, every time a week is approaching, it is necessary to summarize. Boss Yu also warned Xiaoshuai...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn