程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Making simple likes with Python

編輯:Python

Catalog

This blog trial scenario

Like the core logic of the robot

Code level implementation

Simulated Login

Like machine

summary

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 :

Simulated Login ;

Like it ;

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

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 ;

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 :

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 ;

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 ):

CSDN Like interface is as follows :

# POST  Pass user ID and article  IDRequest URL: https://blog.csdn.net//phoenix/web/v1/article/likeRequest 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/likersRequest 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/likeRequest Method: POST# POST  The parameters are as follows aid: 631588341like: 1csrf: 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 requestsdef 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 .

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 .

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 .

That's the use Python Details of making simple likes , More about Python Please pay attention to other related articles of the software development network for the information about the likes !



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved