首页 > 编程语言 > 详细

python爬虫--打开爬取页面

时间:2018-04-26 14:24:39      阅读:220      评论:0      收藏:0      [点我收藏+]
def requests_view(response):
    import webbrowser
    requests_url = response.url
    base_url = ‘<head><base href="%s">‘ %(requests_url)
    base_url = base_url.encode(‘utf-8‘)
    content = response.content.replace(b"<head>",base_url)
    tem_html = open(‘tmp.html‘,‘wb‘)
    tem_html.write(content)
    tem_html.close()
    webbrowser.open_new_tab("tmp.html")

  

python爬虫--打开爬取页面

原文:https://www.cnblogs.com/php-linux/p/8952022.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!