Python 域名目录文本提取脚本
以下是一个简单的 Python 脚本,用于访问一个域名并获取其目录文本:
import requests
from bs4 import BeautifulSoup
url = 'https://www.example.com/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
for link in soup.find_all('a'):
print(link.get('href'))
这个脚本使用 requests 库来访问指定的 url,然后使用 BeautifulSoup 库来解析 HTML 响应。然后,它遍历 HTML 中的所有链接,并打印它们的 href 属性。在实际应用中,您可以将这些链接保存到文件中,或对它们进行其他处理。
原文地址: https://www.cveoy.top/t/topic/lREo 著作权归作者所有。请勿转载和采集!