如何模拟一个http请求并把response的内容保存下载下来,导出到excel中(结尾福利)

 def doExport(self):
        # 模拟一个http请求
        url = u'%s?dumptype=investigation&dumpid=%s&timezone=8' % (self.DUMP_URL, self.task_id)
        # 将请求得到的内容保存下来  ? 表示要调用参数
        content = self.httpGet(url, False, None)
        # 新建一个excel文件
        fh = open(u'D:\\export_log.xlsx',u'wb')
        # 将内容写进去
        fh.write(content)
        fh.close()

不过看起来的几行代码,但是却遇到了很多的小问题:

在这里插入图片描述
看到这个报错之后我就查询了相关错误的类型,发现了这人的博客[https://blog.csdn.net/lmseo5hy/article/details/79446008],然后就一个一个排错误,最后竟然是第三条,天啦噜

小福利:

1.关于如何把http请求得到的内容下载下来,这位的博客会有帮助
https://blog.csdn.net/qq_22521211/article/details/80052085
2.模拟一个http请求:https://www.cnblogs.com/poerli/p/6429673.html
3. 在这里插入图片描述
在这里插入图片描述
5. 讲解了怎么获取http请求得到的resp里面的内容:非常好!https://blog.csdn.net/sinat_28680819/article/details/70940325

posted @ 2018-12-03 14:41  南邮吴亦凡  阅读(336)  评论(0编辑  收藏  举报