Python利用bs解析GitHub Page

Posted by Darren Blog on June 26, 2024

Python利用bs解析GitHub Page

1
2
pip install requests
pip install BeautifulSoup

然后,使用以下代码:

1
2
3
4
5
6
7
8
9
10
import requests
from bs4 import BeautifulSoup
# 网页请求
url = 'https://github.com/Alvin9999/new-pac/wiki/ss免费账号'
# 解析数据
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
#查找pre标签,第二个便是SS链接
lst = soup.find_all('pre')
lst[1].get_text()