欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python 3.x urllib学习

发布时间:2025/7/14 python 36 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python 3.x urllib学习 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

urllib.request

import urllib.request as ur url='http://ie.icoa.cn' user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' req=ur.Request(url) req.add_header('User-Agent',user_agent) res=ur.urlopen(req) html=res.read().decode('utf8') print(html)

发送一个header,模拟浏览器

 

转载于:https://www.cnblogs.com/fj0716/p/5138391.html

总结

以上是生活随笔为你收集整理的python 3.x urllib学习的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。