the battle of baidu online market caused by pornographic resources

Posted by barello at 2020-02-27

Published on April 12, 2017 | classified in reptile Technology | heat degree ℃

The reason for this is that I wanted to find some classic movies to enjoy, so I asked an old driver for resources (I noted the need for regular video, which is definitely not the kind of resources he wanted), and then he gave me a video resource website, which is a famous video resource website. I believe that it is true, then excited to open the search for classic movies, so it led to a classic Baidu online battle. Disclaimer: the tools in this article are only for personal test and research. Please delete them within 24 hours after downloading, and do not use them for commercial or illegal purposes. Otherwise, you will be responsible for the consequences. The screenshots in this article are only for sample demonstration. Do not use them illegally. First, look at the screenshots of this video website: I have to say, this is a regular website, regular video, just looking at the title More. With a great desire for knowledge, I clicked on the link and saw the video resource link at the bottom of the page. There are two kinds of resources here, one is Baidu online disk, the other is Xunlei seed. It has to be said that this website is more conscientious, compared with some websites that only send pictures and don't leave seeds. According to the normal logic, at this time, I should click the resource address to enjoy it quietly (no, actually I am not that person), so I choose to add the resource to the online collection silently. Seeing that there are several more masterpieces on the Internet, I feel very happy. But just adding a few works didn't satisfy my collection desire. So I began to explore how to quickly add video resources to Baidu online, which triggered a series of struggles for Baidu online.

Prelude to war

First of all, by observing the URL composition of the website and the source code composition of the webpage, I decided to use crawling to collect the resource link address. Screenshot of webpage: there is no big problem in this process. I adopted the method of Python + cooperation to collect, and soon got a part of resource address: Baidu online disk resource address:

After writing the script of collecting data, it was 11:00 p.m. after collecting part of the data, I should have washed and slept. However, the power of technology exploration encouraged me to move on. At present, there are all resource addresses. However, for Baidu online disk resources, they still need to be opened one by one, and then added to my online disk. This step is too labor-intensive, so I decided to continue mining the method of automatically adding resources to Baidu online disk.

Note: the following content is the key technical content of this article, which is related to the final outcome of the World War I with Baidu online disk. Please don't go away and continue.

Ultimate battle

First of all, I analyzed the characteristics of Baidu's sharing page by grabbing the package, checking the source code, reviewing the elements, etc., and judged whether it was suitable for the crawler mode. After a series of tests, I found that although the process is a little bit tortuous, it can still add resources to the network disk automatically in the way of crawler.

To implement this technology, I summarize the following processes:

Get cookie

There are many tools for grabbing cookies. I use Firefox's tamper plug-in. The effect is as follows: get the data package of login: check the request package sent by login and find that there is an account password. Of course, what we need here is a cookie, which can be viewed in response.

The format of the cookie is as follows:










PSTM=1421697115; PANWEB=1; Hm_lvt_7a3960b6f067eb0085b7196ff5e660b0=1491987412; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e6260b0=1491988544;





Since this cookie involves a personal account, I made changes, but the format should be the same.

Visit Baidu resource sharing page

For example, after obtains the cookie, when visiting the baidu resource sharing page, I can write the cookie value in the headers and log in using the cookie. During this time, I also failed several times, because other header parameters need to be added (if the cookie parameter is not added, the returned result will be "the page does not exist"). After the request is successful, we can find some content we need in the source code, such as the name of page sharing resource, shareid, from (UK), bdstoken, APP ID (app_id) value.

Construct add resource post package

First, let's look at the structure of the post package:


















Connection: keep-alive

Content-Length: 169

Accept: * / *


X-Requested-With: XMLHttpRequest

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Content-Type: application/x-www-form-urlencoded; charset=UTF-8


Accept-Encoding: gzip, deflate, br

Accept-Language: zh-CN,zh;q=0.8,en;q=0.6



There are some parameters in the URL of the post package. Just fill in the content we get. There is also a login parameter. The content can be written casually. It should be a random value and then base64 encryption is done. In the payload of the post package, filelist is the resource name in the format of filelist = ["/ name. MP4"], and path is saved in that directory. The format path = / path name cookie must be filled in, which is the cookie value we obtained before.

Final return content


{"errno":0,"task_id":0,"info":[{"path":"\/\u5a31\u4e50\u6e38\u620f\/\u4e09\u56fd\u5168\u6218\u6218\u68cb1.4\u516d\u53f7\u7248\u672c.rar","errno":0}],"extra":{"list":[{"from":"\/\u5a31\u4e50\u6e38\u620f\/\u4e09\u56fd\u5168\u6218\u6218\u68cb1.4\u516d\u53f7\u7248\u672c.rar", "to":"\/\u4e09\u56fd\u5168\u6218\u6218\u68cb1.4\u516d\u53f7\u7248\u672c.rar"}]}}

Finally, if you see the above content, it indicates that the resource has been successfully added to the network disk. If errno is another value, it indicates that an error has occurred. 12 indicates that the resource already exists.


After nearly an hour, I finished writing the code, most of which was spent on debugging and researching the data package. During this period, I encountered many pits, but it was finally solved. Enjoy the pleasure when the program is running: the results of Baidu online market:

After that, it's almost midnight to write down this article. I only run a small part of the video resources, and the rest will continue tomorrow. Is it easy for me to watch some videos

Tomorrow I will release the source code. Today I will share my online disk bar:

Project GitHub address:

Welcome to sweep the WeChat official account above and subscribe to my blog!

Popular article recommendation: