python 抓取 https://wwwtest.easytransfer.cn/pay?order_id=ET20230608142808572233&country=CHN 网站 实现代码
时间: 2024-01-02 12:02:41 浏览: 23
你可以使用 Python 中的 requests 和 BeautifulSoup 库来实现这个功能。以下是一个简单的示例代码:
```python
import requests
from bs4 import BeautifulSoup
# 构造请求头
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"}
# 发送 GET 请求
url = "https://wwwtest.easytransfer.cn/pay?order_id=ET20230608142808572233&country=CHN"
response = requests.get(url, headers=headers)
# 解析 HTML
soup = BeautifulSoup(response.content, "html.parser")
print(soup.prettify())
```
这个代码会向指定的 URL 发送 GET 请求,然后使用 BeautifulSoup 解析返回的 HTML 页面。你可以根据具体需求来提取页面中的信息。同时,需要注意的是,这个示例代码中使用了一个自定义的请求头,这是为了模拟浏览器发送请求,避免被服务器拦截。