from urllib import request,parse

from http import cookiejar

cookie = cookiejar.CookieJar()#生成cookie对象
cookie_handler = request.HTTPCookieProcessor(cookie)
http_handler = request.HTTPHandler()#  http请求管理器
https_handler = request.HTTPSHandler()#  https请求管理器
#发起请求管理器
opener = request.build_opener(https_handler,https_handler,cookie_handler)

#登录
def login():
        login_url = "http://www.renren.com/PLogin.do"
        data = {
                "email": "你的人人网账号",
                "password": "你的人人网密码"
        }
        data = parse.urlencode(data)
        req = request.Request(login_url,data=bytes(data,'utf-8'))
        opener.open(req)

def ht():
       
 base_url = 'http://www.renren.com/964508633/profile'#这个通过你的人人网个人主页修改,下面有查找图片
resp = opener.open(base_url).read().decode()
with open('wwww.html', 'w', encoding='utf-8') as f:
                f.write(resp)
if __name__ == "__main__":
    login()
    ht()
python Spider Man(爬虫侠)三,之cookie进行人人网页面爬取

相关文章:

  • 2021-08-07
  • 2021-05-19
  • 2021-11-24
  • 2021-06-20
  • 2021-10-06
  • 2021-10-25
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2021-04-17
  • 2021-12-06
  • 2021-06-13
  • 2021-12-14
  • 2021-05-06
  • 2022-12-23
  • 2021-09-04
相关资源
相似解决方案