demo.py
508 Bytes
# -*- coding: utf-8 -*-
# @Time : 2021/7/28 16:59
# @Author : Ljq
# @File : demo.py
# @Software: PyCharm
"""
"""
import re
from bs4 import BeautifulSoup
with open('demo_b.html',encoding="utf-8") as con:
data = con.read()
soup = BeautifulSoup(data,"html.parser")
all_list = soup.findAll("input")
aa = {i.get("name"):i.get("value") for i in all_list}
print(aa)
# print(aa["autocomplete-cartype"])
# c = [i.get("value") for i in soup.findAll("input") if i.get("name")=="categoryName"]
# print(c)