浏览 391 次
锁定老帖子 主题:python爬取《感动中国》观后感文章
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2022-03-04
import requests import random # 要访问的目标页面 targetUrl = "https://www.baidu.com/" # 要访问的目标HTTPS页面 # targetUrl = "https://www.baidu.com/" # 代理服务器(产品官网 www.16yun.cn) proxyHost = "t.16yun.cn" proxyPort = "31111" # 代理验证信息 proxyUser = "username" proxyPass = "password" proxyMeta = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % { "host" : proxyHost, "port" : proxyPort, "user" : proxyUser, "pass" : proxyPass, } # 设置 http和https访问都是用HTTP代理 proxies = { "http" : proxyMeta, "https" : proxyMeta, } # 设置IP切换头 tunnel = random.randint(1,10000) headers = {"Proxy-Tunnel": str(tunnel)} resp = requests.get(targetUrl, proxies=proxies, headers=headers) print resp.status_code print resp.text获取到的数据需要进行整理后才能给大家看,简单了看下,很多的文章都写的很真诚,正能量,从中也看到了榜样带大家的力量。如果有兴趣的朋友可以去观看下《感动中国》也写写感想。做爬虫的小伙伴也可以借由这个主题试驾下爬虫能力,获取些好的文章分享给大家。若有收获,就点个赞吧 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |