Background:
Get the page you need to sign in to add the cookie you acquired to the requested script after logging in.
Method:
Import requests
Url= "Http://webserver/admin"
cookies = dict (cookies_are= ' cookie content ')
# #cookie内容可在登陆页面后, obtained through the browser tool ().
Response = Requests.get (URL, cookies=cookies)
Print Response.content.decode ("Utf-8")
This allows you to get the Web page source code after landing.
If you want to simulate a more realistic point, it would be better to add the user agent.
My_headers = {' user-agent ': ' mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/45.0.2526.80 safari/537.36 core/1.45.933.400 qqbrowser/ 9.0.8699.400 ', ' accept-encoding ': ' gzip, deflate, SDCH '}
Response = Requests.get (URL, cookies=cookies,headers=my_headers)
Print Response.content.decode ("Utf-8")
As long as it is not specifically targeted, it should generally be treated as normal access by the server.
This article from "Ops said: from rookie to veteran" blog, please be sure to keep this source http://liuqunying.blog.51cto.com/3984207/1836309
Python requests with Cookie access page