python--采集1(urllib模块)

来源:互联网 发布:厦门网络优化 编辑:程序博客网 时间:2024/05/20 05:55
使用urllib模块,首先引入urllib。request使用urlopen方法读取目标Url import urllib.requestresponse = urllib.request.urlopen("http://www.baidu.com")html = response.read()baiduhtml = html.decode("utf-8")print(baiduhtml)#################################<html><head>        <meta http-equiv="content-type" content="text/html;charset=utf-8">    <meta http-equiv="X-UA-Compatible" content="IE=Edge">    <meta content="always" name="referrer">    <meta name="theme-color" content="#2932e1">    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />    <link rel="search" type="application/opensearchdescription+xml" href="/content-search.xml" title="百度搜索" />     <link rel="icon" sizes="any" mask href="//www.baidu.com/img/baidu.svg">        。。。。。。
0 0
原创粉丝点击