获取百度首页中的子链接地址

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))

  

posted @ 2019-10-06 11:18  若水如引  阅读(327)  评论(0编辑  收藏  举报