1. 程式人生 > >python爬蟲--打開爬取頁面

python爬蟲--打開爬取頁面

PE brush OS htm tab quest replace %s class

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爬蟲--打開爬取頁面