English translation
Send an HTTP request to fetch the webpage content
AI Article Decision Snapshot
Turn the lesson into workflow, model, budget, and security checks before choosing tools.
Use this quick snapshot before leaving the article. It keeps the next search tied to practical AI software, model/API, cost, privacy, and implementation questions.
Workflow fit
Identify the real job behind the article: coding, research, document review, support, analytics, content, or internal automation.
Model or tool decision
Decide whether the next step is a software shortlist, an AI tool comparison, an API platform choice, or a model benchmark.
Budget and usage signal
Estimate seats, API calls, prompt volume, retries, review time, and fallback work before assuming the workflow is cheap.
Security and privacy review
Check whether source code, customer data, private documents, prompts, logs, or embeddings will enter the AI workflow.
In the previous article, we completed the installation of Python, ensuring that our computer can run Python code. Next, we need to install several relevant libraries for our software automation project. These libraries will help us perform automation tasks more conveniently—such as web scraping, file processing, and simulating keyboard and mouse operations. This article provides a detailed introduction to commonly used Python libraries and their installation methods.
Commonly Used Libraries
Below are some widely used Python libraries in software automation:
- Requests: Used to send HTTP requests and retrieve web content.
- Beautiful Soup: Used to parse HTML and XML documents; often used alongside Requests.
- Selenium: Enables browser automation by simulating user interactions.
- PyAutoGUI: Controls the mouse and keyboard—ideal for desktop automation tasks.
- Pandas: Designed for data manipulation and analysis, especially well-suited for tabular data.
Tools for Managing the Installation Environment
Before installing these libraries, we recommend using pip to manage Python packages. pip is Python’s official package manager and comes preinstalled with Python 3.4 and later. If you’re using an older version of Python, you may need to install pip manually.
Installing Libraries Using pip
Below are example commands for installing the above libraries using pip. Enter each command in your terminal or command prompt:
pip install requests
pip install beautifulsoup4
pip install selenium
pip install pyautogui
pip install pandas
Example
Let’s walk through a simple use case demonstrating how these libraries work together. Suppose we want to scrape information from a webpage and save it as a CSV file. We’ll use requests and Beautiful Soup to accomplish this:
import requests
from bs4 import BeautifulSoup
import pandas as pd
# Send an HTTP request to fetch the webpage content
url = 'http://example.com'
response = requests.get(url)
# Parse the HTML content using Beautiful Soup
soup = BeautifulSoup(response.text, 'html.parser')
# Extract all links from the page
links = soup.find_all('a')
link_data = []
for link in links:
link_data.append({'text': link.text, 'href': link.get('href')})
# Save the extracted data to a CSV file
df = pd.DataFrame(link_data)
df.to_csv('links.csv', index=False)
In the code above, we first use requests.get() to fetch the webpage content. Then, BeautifulSoup parses the HTML and extracts all <a> tags (i.e., hyperlinks), capturing both their visible text and href attributes. Finally, we store the collected data in a Pandas DataFrame and export it to a CSV file—making it easy to process further.
Installing Selenium and Configuring Browser Drivers
In addition to the libraries listed above, if you plan to use Selenium for browser automation, you must also download and configure a compatible browser driver—for example, ChromeDriver (for Google Chrome) or GeckoDriver (for Firefox). Below are the steps to install ChromeDriver:
- Download the appropriate version of ChromeDriver matching your installed Chrome browser version.
- Place the
chromedriver.exe(Windows) orchromedriver(macOS/Linux) binary either in a directory included in your system’sPATH, or note its full path for later reference.
Once ChromeDriver is properly installed and accessible, you can use Selenium to launch a browser and execute automated actions.
Installing PyAutoGUI
For desktop automation, simply install PyAutoGUI via pip:
pip install pyautogui
Summary
So far, we have successfully installed the essential Python libraries needed for automation tasks. You now have the foundational tools required to begin building automation workflows. In the next article, we’ll further configure our development environment to support efficient coding and debugging. As you read and follow along, pay close attention to each step—this careful foundation will greatly benefit your future learning and projects.
Apply This Lesson
Turn this article into AI software, model, API, and security decisions.
English Article FAQ
Use this article as evidence before choosing AI tools
How should I use this AI Tutorials article?
Use it as the implementation or learning layer, then connect the idea to AI software buyer guides, tool comparisons, benchmarks, API choices, and security checks before making a production decision.
Is this English article different from the Chinese original?
The English edition is localized for global AI readers while preserving the original diagrams, screenshots, prompts, code examples, and source context from the Chinese article.
What should I read after Send an HTTP request to fetch the webpage content?
Continue with AI Software Buyer Guides, AI Tools Workbench, Best AI Coding Agents, AI Model Benchmarks, OpenAI vs Anthropic API, or LLM Security Tools depending on the decision you need to make.
Can this article alone choose an AI product or model?
No. Treat the article as evidence and context, then validate fit with pricing, privacy requirements, integration effort, benchmark results, workflow tests, and fallback planning.
Continue