Home Backend Development Python Tutorial Install chrome and use selenium to realize automatic barrage of Kuaishou

Install chrome and use selenium to realize automatic barrage of Kuaishou

May 04, 2020 pm 04:55 PM
selenium Barrage

Use python's selenium package to realize the automatic barrage process of Kuaishou

1. Prepare the chrome browser and the corresponding version of the webdriver driver

2. python Install the selenium package

3. Log in to Kuaishou in chrome to analyze the process of posting barrages

4. Code implementation

5. Run

1. Install the Google Chrome download driver

##Google official website

(Google Access Assistant plug-in: Link: https://pan.baidu.com/s/1XFazQydGjFyy-UZKTwqjgQ Extraction code: 30kz)

The downloaded one is called Google Access Assistant_v2.3.0.crx extension package

Installation method:

Open the chrome browser, more tools->Extensions-> Just drag it here -> You need to set one of the two URLs as the homepage to use the Chrome browser normally.

Install the webdriver that matches the browser version

1. Open Google Chrome and enter chrome in the address bar ://version/ View version information

Result similar to the following:

Google Chrome 79.0.3945.117 (official version) (64-bit)

Revision 04f0a055010adab4484f7497fbfdbf312c307f1d-refs/branch -heads/3945@{#1019}
Operating system Windows 10 OS (Build 10240.16384)

##2. Select the appropriate version Driver download,

Download address: http://chromedriver.storage.googleapis.com/index.html

3. Place chromedriver.exe in the Python environment directory

For example: D:\server\Python\Python37\chromedriver.exe

## 2. Install selenium package in pythonCommand line: pip install selenium

Compiler pycharm: setting->Project Interpreter just add selenium

Install chrome and use selenium to realize automatic barrage of Kuaishou

3. Log in to Kuaishou in Chrome to analyze the process of posting barrages

Enter the content here in the live broadcast room, and then click send. Therefore, the code must select this input box, write the content operation, and be able to select the send button, and then click the operation. Install chrome and use selenium to realize automatic barrage of Kuaishou

4. Code implementationfrom selenium import webdriver

import time
# Import class library

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\Users\lxs\AppData\Local\Google\Chrome\User Data")
driver=webdriver.Chrome(options=options)
driver.get('https://live.kuaishou.com/u/......?csr=true')#Open a page
time .sleep(2) #Slow for two seconds to allow the web page to load completely
for i in range(0,10): #Loop 10 times, enter 666 10 times
#Through chrome’s css selector
input = driver.find_element_by_css_selector('#app > div.live-detail > div.liveroom-sidebar.light > div.chat > div.chat-actions > div.chat-input > div > textarea')
input.send_keys('六六六') #Input 3 sixes to the element
submit = driver.find_element_by_css_selector('#app > div.live-detail > div.liveroom- sidebar.light > div.chat > div.chat-actions > div.chat-input > div > button')
submit.click() #Click operation



In addition to the above comments, you should also pay attention to the use of css selectors:

Press F12 and select the option in the upper left corner to directly select the required elements on the page. Do the following: right-click copy->selector (because the code is selected in this mode)

Install chrome and use selenium to realize automatic barrage of Kuaishou

5. Run the codeInstall chrome and use selenium to realize automatic barrage of KuaishouRun result:

The program opens chrome by itself and visits the live broadcast room. The six here is what the program itself typed. According to the code, the input submission is looped 10 times in total.

Summary:

Because the actual simulated login has not been written yet, it can only be achieved through this method, and the speed is also slow. Really simulated login will be many times faster. This method is suitable for situations where simulated login cannot be achieved.

The above is the detailed content of Install chrome and use selenium to realize automatic barrage of Kuaishou. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Learn to install Selenium easily using PyCharm: PyCharm installation and configuration guide Learn to install Selenium easily using PyCharm: PyCharm installation and configuration guide Jan 04, 2024 pm 09:48 PM

PyCharm installation tutorial: Easily learn how to install Selenium, specific code examples are needed. As Python developers, we often need to use various third-party libraries and tools to complete project development. Among them, Selenium is a very commonly used library for automated testing and UI testing of web applications. As an integrated development environment (IDE) for Python development, PyCharm provides us with a convenient and fast way to develop Python code, so how

Laravel development: How to use Laravel Dusk and Selenium for browser testing? Laravel development: How to use Laravel Dusk and Selenium for browser testing? Jun 14, 2023 pm 01:53 PM

Laravel development: How to use LaravelDusk and Selenium for browser testing? As web applications become more complex, we need to ensure that all parts of it function properly. Browser testing is a common testing method used to ensure the correctness and stability of an application under various browsers. In Laravel development, you can use LaravelDusk and Selenium for browser testing. This article will introduce how to use these two tools to test

Using Selenium and PhantomJS in Scrapy crawler Using Selenium and PhantomJS in Scrapy crawler Jun 22, 2023 pm 06:03 PM

Using Selenium and PhantomJS in Scrapy crawlers Scrapy is an excellent web crawler framework under Python and has been widely used in data collection and processing in various fields. In the implementation of the crawler, sometimes it is necessary to simulate browser operations to obtain the content presented by certain websites. In this case, Selenium and PhantomJS are needed. Selenium simulates human operations on the browser, allowing us to automate web application testing

How to use Selenium for automated web testing How to use Selenium for automated web testing Aug 02, 2023 pm 07:43 PM

Overview of How to Use Selenium for Web Automation Testing: Web automation testing is a vital part of the modern software development process. Selenium is a powerful automated testing tool that can simulate user operations in a web browser and implement automated testing processes. This article will introduce how to use Selenium for web automation testing, and come with code examples to help readers get started quickly. Environment preparation Before starting, you need to install the Selenium library and web browser driver

Use the combination of Java, Selenium and OpenCV to solve the problem of slider verification in automated testing. Use the combination of Java, Selenium and OpenCV to solve the problem of slider verification in automated testing. May 08, 2023 pm 08:16 PM

1. Slider verification idea The slider object of the object under test looks like this. Relatively speaking, it is a relatively simple form. You need to drag the puzzle on the left through the slider below and embed it into the empty slot on the right to complete the verification. To automate this verification process, the key point is to determine the distance the slider slides. According to the above analysis, the key point of verification is to determine the sliding distance of the slider. But a seemingly simple requirement is not simple to complete. If you use natural logic to analyze this process, it can be broken down as follows: 1. Locate the position of the puzzle on the left. Since the shape and size of the puzzle are fixed, you only need to locate the distance between its left border and the left side of the background image. (Actually, in this example, the starting position of the puzzle is also fixed, saving

How to close Kugou music barrage_How to close Kugou music barrage How to close Kugou music barrage_How to close Kugou music barrage Mar 26, 2024 am 08:56 AM

1. First open the Kugou music playback interface. 2. Then click Comments on the playback interface. 3. Enter the comment and you can see the comment option above. 4. Finally, choose to close the review and return to the playback interface.

Where is the Youku barrage setting? Where is the Youku barrage setting? Feb 29, 2024 pm 09:49 PM

In the software Youku, we can freely turn on and off the barrage, and we can also adjust the display settings of the barrage. Some users don’t know where Youku’s barrage settings are. The article introduces how to set up the mobile phone and computer. The editor below will introduce you to the barrage setting method. Let’s take a look at this article. Where to set up the Youku barrage mobile version? 1. Enter any Youku video, click on the middle of the video, and then click on the full screen on the lower right. 2. Click in the middle of the video again and click on the three dots on the upper right. 3. You can see [Barrage Settings] on the upper right. 4. Click to enter to set up the barrage display. PC version 1. Enter Youku and select any video. 2. In the line below the video, you can see the [pop-up] of the settings icon in the lower right corner. 3. Click to play

Efficiently crawl web page data: combined use of PHP and Selenium Efficiently crawl web page data: combined use of PHP and Selenium Jun 15, 2023 pm 08:36 PM

With the rapid development of Internet technology, Web applications are increasingly used in our daily work and life. In the process of web application development, crawling web page data is a very important task. Although there are many web scraping tools on the market, these tools are not very efficient. In order to improve the efficiency of web page data crawling, we can use the combination of PHP and Selenium. First, we need to understand what PHP and Selenium are. PHP is a powerful

See all articles