2023-07-14 18:50:36 +08:00

16 lines
420 B
Python

import requests
from bs4 import BeautifulSoup
# 标准访问格式
def Link(url, headers):
try:
response = requests.get(url, headers=headers)
response.raise_for_status() # 检查请求是否成功
html = response.text
soup = BeautifulSoup(html, 'html.parser')
return soup
except requests.exceptions.RequestException as e:
print("Wrong:", e)
return None