Home  >  Article  >  Backend Development  >  Teach you step by step how to do a keyword matching project (search engine)----On the seventh 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 seventh day, teach you how to do it----_PHP Tutorial

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

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

The seventh day

Xiao Shuai Shuai took it back and studied it carefully all night.

I found out that the code was actually written by myself, and there were a few more classes. Boss Yu had not copied my code, and he despised Boss Yu in his heart.

In fact, everyone has a common problem. Those who write procedures will always despise writing object-oriented, because they do not understand what object-oriented is, and it will take several years for them to write it well.

When Xiao Shuaishuai learned programming, he clearly knew that there was a concept of function and how to write a function, but in fact, even if there were hundreds of lines of code in a function, he didn’t know how to come up with multiple functions in advance, just to make an appointment. : Look how awesome I am, with hundreds of lines of code.

Although Xiao Shuaishuai despises Boss Yu in his heart, he feels very refreshed when he sees Boss Yu’s code, everything is so natural.

But he still couldn’t help but ask Boss Yu:

"Boss Yu, actually your code is the same as mine. Why do you write it like this? What are the benefits of writing it like this?"

Boss Yu said: "Well, yes, the codes are basically the same, and sometimes there are some more codes. Did you find out during the comparison process that the code I wrote is correct? Your code is summarized and categorized."

Object-oriented is actually the summary and classification of process-oriented.

It’s a pity that Xiao Shuaishuai still doesn’t understand it well. Although he is not very happy in his heart, after all, he is the boss, so he is right to listen to his words.

Xiao Shuaishuai replied: "Well, yes, then I can extend it by inheriting Source."

Boss Yu returned: "Well, yes, the inherited Source only needs to assign values ​​to the attribute keywords inside. Isn't it very convenient? If you are not familiar with object-oriented, I suggest you learn these basics first. ".

Object-oriented: Object Oriented (OO) is a software development method. Object-oriented concepts and applications have transcended programming and software development and expanded to fields such as database systems, interactive interfaces, application structures, application platforms, distributed systems, network management structures, CAD technology, artificial intelligence and other fields. [From Baidu entry]

"Object-oriented" specifically refers to the use of design methods such as encapsulation, inheritance, and polymorphism in programming.

Boss Yu continued: "You can continue to expand one according to my method to deepen your thinking. Just the "Are you looking for it?" task."

Xiao Shuai Shuai replied: "Okay".

Xiao Shuai Shuai completed the task in less than an hour.

The requested keyword is plus size women's clothing, the address is: http://s.taobao.com/search?spm=1.7274553.1997520241.2.RsphTP&q=%C5%AE%D1%A9%B7%C4%C9% C0&refpid=420461_1006&source=tbsy&style=grid&tab=all

HTML:

<span><</span><span>dl </span><span>class</span><span>="supplement-relate"</span><span>></span>
    <span><</span><span>dt</span><span>></span>您是不是想找:<span></</span><span>dt</span><span>></span>
    <span><</span><span>dd</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?spm=a230r.1.0.0.TjhJTC&amp;q=%D1%A9%B7%C4%C9%C0%C5%AE2014&amp;rs=up&amp;rsclick=1"</span><span> data-spm-anchor-id</span><span>="a230r.1.0.0"</span><span>></span>雪纺衫女2014<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AE%D1%A9%B7%C4%C9%C0%B3%A4%BF%EE&amp;rs=up&amp;rsclick=2"</span><span>></span>女雪纺衫长款<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%B4%F3%C2%EB%C5%AE%D1%A9%B7%C4%C9%C0&amp;rs=up&amp;rsclick=3"</span><span>></span>大码女雪纺衫<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%D1%A9%B7%C4%C9%C0%C5%AE%B6%CC%D0%E4&amp;rs=up&amp;rsclick=4"</span><span>></span>雪纺衫女短袖<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%D1%A9%B7%C4%C9%C0+%C5%AE+%B3%A4%D0%E4&amp;rs=up&amp;rsclick=5"</span><span>></span>雪纺衫女长袖<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C1%AC%D2%C2%C8%B9&amp;rs=up&amp;rsclick=6"</span><span>></span>连衣裙<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AEt%D0%F4&amp;rs=up&amp;rsclick=7"</span><span>></span>女t恤<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%B4%F3%C2%EB%C5%AE%D7%B0&amp;rs=up&amp;rsclick=8"</span><span>></span>大码女装<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AE%D1%A9%B7%C4%C9%C0%B0%D7%C9%AB&amp;rs=up&amp;rsclick=9"</span><span>></span>女雪纺衫白色<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AE%D1%A9%B7%C4%C9%C0%D6%D0%D0%E4&amp;rs=up&amp;rsclick=10"</span><span>></span>女雪纺衫中袖<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AE%D1%A9%B7%C4%C9%C0%CC%D7%D7%B0&amp;rs=up&amp;rsclick=11"</span><span>></span>女雪纺衫套装<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%CE%DE%D0%E4%D1%A9%B7%C4%C9%C0%C5%AE&amp;rs=up&amp;rsclick=12"</span><span>></span>无袖雪纺衫女<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=%C5%AE%D1%A9%B7%C4%C9%C0%B3%A4%D0%E4%D0%C2%BF%EE&amp;rs=up&amp;rsclick=13"</span><span>></span>女雪纺衫长袖新款<span></</span><span>a</span><span>></span>
                    <span><</span><span>a </span><span>trace</span><span>="relatedSearch"</span><span> href</span><span>="/search?q=2014%D1%A9%B7%C4%C9%C0+%C5%AE+%B6%CC%D0%E4&amp;rs=up&amp;rsclick=14"</span><span>></span>2014雪纺衫女短袖<span></</span><span>a</span><span>></span>
            <span></</span><span>dd</span><span>></span>
<span></</span><span>dl</span><span>></span>

Xiao Shuai Shuai’s code:

<span>class</span> TaobaoRelatedSearchSource <span>extends</span><span> Source
{
    
    </span><span>public</span> <span>function</span><span> __construct()
    {
        </span><span>#</span><span> code...</span>
        <span>$curl</span> = <span>new</span><span> ExtendedCurl();
        </span><span>$content</span> = <span>$curl</span>->get("http://s.taobao.com/search?spm=1.7274553.1997520241.2.RsphTP&q=%C5%AE%D1%A9%B7%C4%C9%C0&refpid=420461_1006&source=tbsy&style=grid&tab=all"<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(".supplement-relate a[trace==relatedSearch]") <span>as</span> <span>$ele</span><span>){
            </span><span>$this</span>->keywords[] = <span>$ele</span>-><span>innertext;
        }

    }
}</span>

Xiao Shuai Shuai showed the code to Boss Yu and was praised by Boss Yu, which made him feel happy. However, Xiao Shuaishuai still does not understand the true meaning of object-oriented.

Shortly after Xiao Shuai Shuai was happy, he was troubled again. The reason was how to use Taobao API and how to get baby information? Where does the information come from?

Little Shuaishuai had no choice but to run to the boss again and ask for advice on how to defeat the enemy.

Boss Yu first asked him to read the Taobao API tutorial and gave him a URL: http://open.taobao.com for Xiao Shuaishuai to read by himself.

Xiao Shuai Shuai had to silently despise Boss Yu in his heart again. He asked me to go and see him. Why do you want me to see him? As soon as this strange thought came to him, Xiao Shuai Shuai quickly shook his head, trying to keep his mind clear. Keep thinking about it.

Just like that, Xiao Shuaishuai went to Taobao open platform to learn from it, and all the object-oriented things were forgotten. (0 Without actual training and understanding, I still follow the boss’s ideas 0)

PS: (Learning is a personal matter, and the project director only leads the door. Whether you can succeed or not depends on the individual. In fact, many people have this idea just like Xiao Shuaishuai, and some people will question someone’s ability. )

What is the Taobao program [[[Only 148 yuan in the last three days. Fashion Taoke--Haodian 8 program group purchase (store navigation + API program + SEO Friendly Article Department

Wangdao SEO optimization software works on search engine optimization. My personal understanding of search engine optimization is that SEO creates and uses keyword optimization to help small and medium-sized enterprises’ websites rank higher in search engine query results to obtain the most effective user clicks. . It is based on the retrieval characteristics of search engines for web pages, so that the basic elements of website construction are suitable for the retrieval principles of search engines, so that the search engines can include as many web pages as possible and rank high in the natural retrieval results of search engines, ultimately reaching the website Promotional purposes. The main work of Wangdao search engine optimization is to optimize web content by understanding how various search engines crawl Internet pages, how to index them, and how to determine their ranking of search results for a specific keyword. , a technology that makes it in line with users' browsing habits, improves search engine rankings without damaging user experience, thereby increasing website visits, and ultimately improving the website's sales or publicity capabilities. The so-called "search engine optimization for Wangdao" is to make the website more easily accepted by search engines.

Who is the Hengshui agent of 360 search engine?

360 search engine has agents in Hebei

What are the advantages of 360 promotion

Rich resources - covering many traffic entrances such as 360 navigation, 360 search, etc., with rich display locations and display forms to meet the needs of enterprises Diverse needs. Simple operation - humanized design, fast delivery process, simple and flexible operation, you only need to open an account to achieve self-service delivery. Precise positioning - through keyword matching and delivery by time period, region, and user group, we can accurately target the target user group and display more accurate promotional information for the enterprise. Intelligent and efficient - professional statistical methods and various data reports ensure the scientificity and rigor of 360 promotion; only charging is based on results, truly achieving lower investment and higher returns!
360 search Hebei area processing: 1111

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/861532.htmlTechArticleTeach you step by step how to do keyword matching projects (search engines)----On the seventh day, teach you how to do- --- On the seventh day, Xiao Shuai Shuai took it back and studied it carefully all night. I found that the code was actually written by myself...
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