current position:Home>Universal Python praise device for the whole network -- self built praise artifact (various application scenarios such as blog and B station)

Universal Python praise device for the whole network -- self built praise artifact (various application scenarios such as blog and B station)

2022-05-15 06:12:51Little genius learning machine playing games

In today's , Any community platform , All have the like function , What came into being was the automatic likes machine , Commonly known as brush extension / Praise machine .

This article will introduce you to a like robot , The most simple and easy to understand core logic .

Pseudo code involved in the full text , Use Python To write , Because it's pseudo code , Don't understand, Python, You can understand .

This blog trial scenario

This time I like robot , It's mainly for computers Web Site , Don't involve APP End .

Like the core logic of the robot

Simulation click operation , Trigger likes , Like to wait for the operation .

Before you like it , There's another important code implementation , Simulated Login .

therefore , The basic requirements of the like robot are as follows :

1. Simulated Login ;

2. Like it ;

After extending this requirement , There are two common business scenarios .

1. Log in to a large number of accounts through simulation , Implement for “ One person / One thing / One article / A video ” A lot of likes , That is to brush others' points ;

2. By logging into an account , Implement for “ Many people ” I like it in bulk , That is to brush your own points .

Code level implementation

After sorting out the basic logic , You can enter the actual coding process .

Simulated Login

On the login implementation , There are two ways of thinking :

1. A lot of registration ( You can also buy ) account number , adopt Python The program switches accounts , Every time I log in like , Switch to the next account ;

2. Advance by technical or manual means , Simulated Login , Record the account generated after login Cookie, Follow up maintenance Cookie The pool implements the operation logic .

The second problem is Cookie The issue of validity , If the website has no such restriction , It is suggested that this method be adopted , More efficient .

Pseudo code implementation

#  Train of thought 
with open("users.txt","r") as f:
 user_pass = f.readline()
 #  Simulated Login 
 login(user_pass)
 #  Complete the post login operation 
 do_someting()

#  Train of thought two 
with open("cookies.txt","r") as f:
 one_cookie = f.readline()
 #  By carrying  cookie  Parameter access interface 
 get_detail(one_cookie)

with open("users.txt","r") as f:
 user_pass = f.readline()
 #  Simulated Login 
 login(user_pass)
 #  Complete the post login operation 
 do_someting()

#  Train of thought two 
with open("cookies.txt","r") as f:
 one_cookie = f.readline()
 #  By carrying  cookie  Parameter access interface 
 get_detail(one_cookie)


with open("users.txt","r") as f:
 user_pass = f.readline()
 #  Simulated Login 
 login(user_pass)
 #  Complete the post login operation 
 do_someting()

#  Train of thought two 
with open("cookies.txt","r") as f:
 one_cookie = f.readline()
 #  By carrying  cookie  Parameter access interface 
 get_detail(one_cookie)
#  Train of thought 
with open("users.txt","r") as f:
 user_pass = f.readline()
 #  Simulated Login 
 login(user_pass)
 #  Complete the post login operation 
 do_someting()

#  Train of thought two 
with open("cookies.txt","r") as f:
 one_cookie = f.readline()
 #  By carrying  cookie  Parameter access interface 
 get_detail(one_cookie)

The second one is Cookie pool , It can be created manually or by program .

In the simulation login section , You will encounter two learning difficulties

1. Verification code identification problem ;

2.IP Anti climbing limit .

  • One of the most accessible solutions , Docking coding platform .
  • The second difficulty is the solution , Buy IP Agent pool , You can also build your own agent pool , Focus on project cost and stability requirements .

Like machine

In many projects , When you have finished the simulated Login operation , Has said that the website is good for you It's completely open .

The next thing you need to do is find the like interface , For example, the following case ( For reference only ):

Blog Like interface is as follows :

# POST  Pass user ID and article  ID
Request URL: https://blog.csdn.net//phoenix/web/v1/article/like
Request Method: POST
# POST  The parameters are as follows 
articleId=118558076

Zhihu like interface is as follows :

#  direct  POST  Pass on , The user ID is in  Cookie  in 
Request URL: https://www.zhihu.com/api/v4/zvideos/1391420717800554497/likers
Request Method: POST

bilibili Like interface is as follows :

#  Passing the user ID at the same time , Pass the corresponding parameters 
Request URL: https://api.bilibili.com/x/web-interface/archive/like
Request Method: POST
# POST  The parameters are as follows 
aid: 631588341
like: 1
csrf: b39b26b6b8071e2f908de715c266cb59

Through the above cases , You'll find that , The format of the like operation interface is basically similar , It's all through POST Pass on Cookie With specific parameters to the server .

among B The station is special , With one csrf Parameters , This parameter can be accessed from Cookie It's extracted directly from .

Pseudo code implementation

import requests

def like(params):
 #  Request header  Cookie  Obtained by simulated Login 
 cookie = get_cookie()
 # cookie = login()
 headers = {
    
  " Other attributes ":" Property value ",
  "Cookie":cookie #  Focus on the user ID  Cookie
 }
 res = requests.post(" Address "," Parameters "," Request header ")

In the call like interface section , You will come across a learning difficulty

  • The interface contains positional parameters , For example, the above B The site likes csrf, For solutions to unknown parameters, please refer to the following description .

Keep taking it B For example , Open browser developer tools , Switch to network tab , When you click like , There will be like data requests , As shown in the figure below .

 Insert picture description here
The request appeared at the same time POST Related parameters of , Next , All you have to do is press on the keyboard Ctrl+F, Open the search window ( It's in the current developer tools network Tab ), In the search box , Enter the value to retrieve , You can find all the request locations where the value appears , Then follow up analysis can be done . The key point is to find the position and principle of the parameter value .

 Insert picture description here

Like robot summary

There are various application scenarios of auto like robot , Accurately speaking , This operation can cause some platform imbalances , It will also affect the fairness of platform data , But it's because of the demand , So there are a lot of likes on the market right now , Brush divider , Commenter , There are even a large number of companies running such businesses .

We don't support this kind of business , But you can learn how it works . After all, use Python Implement an automation tool , After understanding the principle , It's going to be very simple .

About Python Technology reserve

Learn from good examples Python Whether it's employment or sideline, it's good to make money , But learn to Python Still have a learning plan . Finally, let's share a complete set of Python Learning materials , For those who want to learn Python Let's have a little help !

One 、Python Learning routes in all directions

Python All directions are Python Sort out the common technical points , Form a summary of knowledge points in various fields , The use of it is , You can find the corresponding learning resources according to the above knowledge points , Make sure you learn more comprehensively .

Two 、 Learning software

If a worker wants to do a good job, he must sharpen his tools first . Study Python Common development software is here , It saves you a lot of time .

3、 ... and 、 Getting started video

When we were watching videos to learn , You can't just move your eyes and brain without hands , A more scientific way to learn is to use them after understanding , At this time, the hand training program is very suitable .

Four 、 Practical cases

Optical theory is useless , Learn to knock together , Do it , Can you apply what you have learned to practice , At this time, we can make some practical cases to learn .

5、 ... and 、 Interview information

We learn Python Must be to find a well paid job , The following interview questions are from Ali 、 tencent 、 The latest interview materials of big Internet companies such as byte , And the leader Ali gave an authoritative answer , After brushing this set of interview materials, I believe everyone can find a satisfactory job .


This full version of Python A full set of learning materials has been uploaded CSDN, Friends can scan the bottom of wechat if necessary CSDN The official two-dimensional code is free 【 Guarantee 100% free

copyright notice
author[Little genius learning machine playing games],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/135/202205142244414354.html

Random recommended