【发布时间】:2023-01-04 06:11:16
【问题描述】:
我编写了以下代码来打开保存在桌面上的本地 HTML 文件:
但是,在运行此代码时出现以下错误:
我以前没有用 Python 或 BS4 处理这个的经验。网上试了各种解决办法都解决不了。
代码:
import csv
from email import header
from fileinput import filename
from tokenize import Name
import requests
from bs4 import BeautifulSoup
url = "C:\ Users\ ASUS\ Desktop\ payment.html"
page=open(url)
# r=requests.get(url)
# htmlContent = r.content
soup = BeautifulSoup(page.read())
head_tag = soup.head
for child in head_tag.descendants:
print(child)
需要帮忙!
先感谢您。
【问题讨论】:
标签: python beautifulsoup html-parsing offline