1、什么是Urllib?

爬虫--Urllib库详解

2、相比Python2的变化

爬虫--Urllib库详解

3、用法讲解

(1)urlopen

urlllb.request.urlopen(url,data=None[timeout,],cahle=None,capath=None,cadefault=False,context=None)
#第一个参数为url网址,第二个参数为额外的数据,第三个参数为超时的设置,剩下的参数暂时用不到
######### GET 类型的请求 #############
import urllib.request
response =urllib.request.urlopen("http://ww.baidu.com")
print(response.read().decode("utf-8")
<!DOCTYPE html>
<!--STATUS OK-->

·······················

······················

·····················

<script>
if(navigator.cookieEnabled){
document.cookie="NOJS=;expires=Sat, 01 Jan 2000 00:00:00 GMT";
}
</script>

</body>
</html>
打印的结果为:

相关文章:

  • 2021-09-17
  • 2021-05-14
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2021-05-28
  • 2021-10-12
  • 2022-12-23
  • 2021-10-20
  • 2021-05-22
  • 2022-12-23
相关资源
相似解决方案