import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 QQBrowser/4.4.106.400",
"Connection": "keep-alive",
"Accept-Language": "zh-CN,zh;q=0.9",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"}
html=requests.get("https://car.autohome.com.cn/price/brand-33.html",headers=headers)
html.encoding = "gb2312"
soup = BeautifulSoup(html.text,"lxml")
-sharp
xx=soup.find("h2","class_=fn-left name")
yy=xx.find("a")
print(yy["href"]) -sharph2
"""
<h2 class="fn-left name"><a href="/price/brand-33.html"></a></h2>
"""```