获取百度首页中的子链接地址
import os
import requests
from bs4 import BeautifulSoup
import lxml
def Gethtml(url):
response=requests.get(url)
response.encoding="utf-8"
# print(response.text)
return response.content
def parseHtml(html):
msg=BeautifulSoup(html,features="lxml")
for item in msg.findAll("a"):
print(item.get("href"))
#print(msg)
url="http://wwww.baidu.com"
#Gethtml(url)
parseHtml(Gethtml(url))

浙公网安备 33010602011771号