码迷,mamicode.com
首页 > 编程语言 > 详细

python 爬虫 伪装

时间:2018-04-25 17:14:30      阅读:986      评论:0      收藏:0      [点我收藏+]

标签:.com   close   爬虫   imp   enc   import   pytho   use   agent   

#coding=utf-8
import requests


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")
headers = {"User-Agent":‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36‘}
proxies = {‘https‘:"114.215.107.94:60443",‘http‘:"211.147.67.150:80"}
requests_view(requests.get("http://www.spbeen.com/tool/request_info/",headers=headers,proxies=proxies))

  

python 爬虫 伪装

标签:.com   close   爬虫   imp   enc   import   pytho   use   agent   

原文地址:https://www.cnblogs.com/php-linux/p/8945324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!