#!usr/bin/env python #-*- coding:utf-8 _*- """ @author:lenovo @file: 登陸人人網.py @time: 2019/10/{DAY} """ # import requests # # 建立session對象,能夠保存Cookie值 # ssion = requests.session() # # # 處理 headers # headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"} # # #須要登陸的用戶名和密碼 # data = {"email":"1868156XXXX", "password":"XXXX"} # # # 發送附帶用戶名和密碼的請求,並獲取登陸後的Cookie值,保存在ssion裏 # ssion.post("http://www.renren.com/PLogin.do", data = data) # # # ssion包含用戶登陸後的Cookie值,能夠直接訪問那些登陸後才能夠訪問的頁面 # response = ssion.get("http://www.renren.com/972540941/newsfeed/photo") # # result = response.content # # html = result.decode('utf-8') # print(html) # filename = "log.html" # with open(filename,'w',encoding='utf-8') as f: # f.write(html)