Hello, everyone. Today we bring you a share of Python crawlers, continue to explore the tiger tooth platform crawlers.
The cause of
After writing the code last time, I had an interesting idea that we could use Selenium to implement an automatic login program and automatically send a bullet screen function to anchors. Now that we have an idea, we start to implement it. First of all, we need to make sure to enter a live broadcast room, and then send the bullet screen. I choose the live broadcast room of Tiger’s Fang No.1 chess Emperor – Snake Brother in league of Legends (you can choose your favorite host to send the bullet screen), as shown below:
To analyze problems
The amount of bullet screen is really (I don’t know how many real people and robots), and I don’t know if there are boring people like us who have to write code to watch the live broadcast (haha).
But we often watch live broadcast, or people who have sent the bullet screen, should know that we have to log in to realize the function of sending the bullet screen, so here we need to log in the account first.
Code implementation
Here in order not to expose their accounts and passwords, HERE I also do not repeat. Here I use the sleeping function time to wait for the user to log in manually, as shown below:
Before login, we need to find the login button, here to explain that I am not rigorous procedures, if more than 15 seconds did not log in, then the program will crash, we suggest to see how to automatic login.
Then we just need to find the entry to send the barrage and write the text, as shown below:
Here we use code to achieve, just write an infinite loop to control the sending of bullets can be, the code is as follows:
So we’re done with all the code, Nani? So that’s it, sounds complicated, is it code to implement? Yes, there it is, the general code:
conclusion
To sum up, the code can also be optimized, such as: 1. We can get the content of a few seconds sent by other users, we can directly send the content again, so that the content sent will not be incompatible with other bullets; 2. 2. We can also use code to automatically pick up things like gifts, etc.
Finally, I thought that if our code was a little more intelligent, we could become some keymen or trolls on the network. I would also like to say that every industry is not easy, so don’t spread some negative comments on the Internet, even if we see similar comments should not be accepted, even if you can think of these comments as a piece of code sent out.