qq cookie

from selenium import webdriver
from selenium.webdriver import ActionChains
import time, re, os, requests
from PIL import Image

def get_cookie():
    print('开始')
    chrome_options = webdriver.ChromeOptions()
    # # 使用headless无界面浏览器模式
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--no-sandbox')
    # 谷歌文档提到需要加上这个属性来规避bug
    chrome_options.add_argument('--disable-gpu')
    # 设置默认编码为utf-8
    chrome_options.add_argument('lang=zh_CN.UTF-8')
    ## 隐藏滚动条, 应对一些特殊页面
    chrome_options.add_argument('--hide-scrollbars')
    # 禁止加载图片
    # chrome_options.add_argument('blink-settings=imagesEnabled=false')
    # 指定浏览器分辨率
    chrome_options.add_argument('window-size=1440x900')
    driver = webdriver.Chrome(chrome_options=chrome_options, executable_path='/root/yu/01-chromedriver/chromedriver')
    driver.get('https://www.wegame.com.cn/store/games')
    # driver.maximize_window()
    ac = driver.find_element_by_xpath('//*[@id="header_wrapper"]/div/div[3]/div[1]/a/span')
    ActionChains(driver).move_to_element(ac).click(ac).perform()
    time.sleep(1)
    iframe = driver.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div[3]/iframe')   # 切换到这个iframe  不切换获取不到xpath坐标
    driver.switch_to.frame(iframe)
    time.sleep(2)
    ac = driver.find_element_by_xpath('//*[@id="switcher_plogin"]')
    ActionChains(driver).move_to_element(ac).click(ac).perform()
    time.sleep(1)
    driver.find_element_by_xpath('//input[@id="u"]').clear()
    for i in '2649942575':
        # for i in '1064145110':
        driver.find_element_by_xpath('//input[@id="u"]').send_keys(i)
        time.sleep(0.2)
    driver.find_element_by_xpath('//input[@id="p"]').clear()
    for i in 'yu1064145110':
        # for i in 'zhangyan1216':
        driver.find_element_by_xpath('//input[@id="p"]').send_keys(i)
        time.sleep(0.2)
    ac = driver.find_element_by_xpath('//*[@id="login_button"]')
    ActionChains(driver).move_to_element(ac).click(ac).perform()
    time.sleep(2)
    print('-' * 100)
    html = driver.page_source
    if '安全验证' in html:
        imgelement = driver.find_element_by_xpath('//*[@id="qrlogin_img"]')
        locations = imgelement.location  # 获取当前位置坐标  定点
        print('locations:{}'.format(locations))
        sizes = imgelement.size   # 获取xpath取到的图片大小
        print('sizes:{}'.format(sizes))
        driver.switch_to.default_content()   # 切换到主页
        iframe_l = driver.find_element_by_xpath('/html/body/div[4]/div/div/div[2]/div[3]/iframe')
        locations_l = iframe_l.location
        print('locations_l:{}'.format(locations_l))
        rangle = (locations['x'] + locations_l['x'], locations['y'] + locations_l['y'],
                  locations['x'] + sizes['width'] + locations_l['x'],
                  locations['y'] + sizes['height'] + locations_l['y'])   # 要切图片的坐标(x, y, x, y) 第一个是 第一点坐标    后面xy 是第二点坐标   两点获取一个面
        path = os.path.dirname(os.path.abspath(__file__))
        driver.save_screenshot('{}/iamge.png'.format(path))   # 数据保存为图片
        # 打开截图切割
        img = Image.open('{}/iamge.png'.format(path))   # 读取要切割的图片
        jpg = img.crop(rangle)
        jpg.save('{}/iamges.png'.format(path))   # 保存切割下的图片
        jpgzoom = Image.open('{}/iamges.png'.format(path))
        (x, y) = jpgzoom.size
        x_s = x * 3
        y_s = y * 3
        out = jpgzoom.resize((x_s, y_s), Image.ANTIALIAS)
        out.save('{}/zoom.png'.format(path), quality=95)   # 保存放大后的图片
        # driver.quit()
        print('请快速扫码登入')
        time.sleep(20)
    print('-' * 1000)
    # driver.switch_to.default_content()
    time.sleep(2)
    aa_cookie = driver.get_cookies()   # 获取cookie
    print("aa_cookie:{}".format(aa_cookie))
    print('+' * 100)
    cookie = {}
    cookies = []  # 拼cookie
    for i in aa_cookie:
        cookie[i["name"]] = i["value"]
        cookies.append('{}={}'.format(i["name"], i["value"]))
    print('cookie:{}'.format(cookie))
    print('cookies:{}'.format('; '.join(cookies)))
    time.sleep(500)
    driver.quit()

if __name__ == '__main__':
    get_cookie()

  

qq cookie的更多相关文章

  1. C#7.2——编写安全高效的C#代码 c# 中模拟一个模式匹配及匹配值抽取 走进 LINQ 的世界 移除Excel工作表密码保护小工具含C#源代码 腾讯QQ会员中心g_tk32算法【C#版】

    C#7.2——编写安全高效的C#代码 2018-11-07 18:59 by 沉睡的木木夕, 123 阅读, 0 评论, 收藏, 编辑 原文地址:https://docs.microsoft.com/ ...

  2. 腾讯QQ会员中心g_tk32算法【C#版】

    最近用C#写qq活动辅助类程序,碰到了会员签到的gtk算法不一样,后来网上找了看,发现有php版的(https://www.oschina.net/code/snippet_1378052_48831 ...

  3. Python_小林的爬取QQ空间相册图片链接程序

    前言 昨天看见某人的空间有上传了XXXX个头像,然后我就想着下载回来[所以本质上这是一个头像下载程序],但是一个个另存为太浪费时间了,上网搜索有没有现成的工具,居然要注册码,还卖45一套.你们的良心也 ...

  4. 在父页面和其iframe之间函数回调 父页面回调iframe里写的函数

    // @shaoyang  父页面 window['mengBanLogin']={ mengBanArr : new Array(), mengBanLoginSuccess : function( ...

  5. Java版 QQ空间自动登录无需拷贝cookie一天抓取30WQQ说说数据&流程分析

    QQ空间说说抓取难度比较大,花了一个星期才研究清楚! 代码请移步到GitHub GitHub地址:https://github.com/20100507/Qzone [没有加入多线程,希望你可以参与进 ...

  6. QQ浏览器兼容模式下Cookie失效 导致的NetCore Cookie认证失效

    最近在写NetCore项目采用的是NetCore的Cookie认证.结果偶然发现QQ浏览器登录不好用.这里先需要了解一下set-cookie中的SameSite属性  导致原因 首先Fiddler 4 ...

  7. ASP.NET Core SameSite 设置引起 Cookie 在 QQ 浏览器中不起作用

    最近在发布了基于 ASP.NET Core 实现的新版登录页面之后,陆陆续续地接到用户反馈登录时 Antiforgery Token 总是验证失败. 日志中记录的对应错误是 Antiforgery t ...

  8. QQ浏览器、搜狗浏览器等兼容模式下,Asp.NetCore下,Cookie、Session失效问题

    原文:QQ浏览器.搜狗浏览器等兼容模式下,Asp.NetCore下,Cookie.Session失效问题 这些狗日的浏览器在兼容模式下,保存Cookie会失败,是因为SameSiteMode默认为La ...

  9. QQ空间动态爬虫

    作者:虚静 链接:https://zhuanlan.zhihu.com/p/24656161 来源:知乎 著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 先说明几件事: 题目的意 ...

随机推荐

  1. .net core 微服务通讯组件Orleans的使用与配置

    Orleans非常好用 并且支持.net core 社区也非常活跃 Orleans2.0+在国内的教程偏少 多数是1.5版本的教程 在这里写上四篇Orleans教程 目录 1.Orleans的入门教程 ...

  2. Day 06 作业

    目录 Python基础实战之猜数字游戏 Python进阶实战之三级菜单 Python基础实战之猜数字游戏 给定数字,用户可以猜三次年龄 数字猜对,让用户选择两次奖励 用户选择奖励后可以退出 impor ...

  3. 【重温基础】JS中的常用高阶函数介绍

    Ps. 晚上加班到快十点,回来赶紧整理整理这篇文章,今天老大给我推荐了一篇文章,我从写技术博客中收获到了什么?- J_Knight_,感受也是很多,自己也需要慢慢养成记录博客的习惯,即使起步艰难,难以 ...

  4. 【Canvas】311- 解决 canvas 在高清屏中绘制模糊的问题

    点击上方"前端自习课"关注,学习起来~ 一.问题分析 使用 canvas 绘制图片或者是文字在 Retina 屏中会非常模糊.如图: 因为 canvas 不是矢量图,而是像图片一样 ...

  5. selenium处理弹窗

    处理登录弹窗:https://www.cnblogs.com/TD1900/p/11938573.html #定位弹窗 ale = driver.switch_to.alert #处理方式 ale.a ...

  6. C语言每日一练——第7题

    一.题目要求 已知数据文件in.dat中存有200个四位数,把这些数存到数组a中,编写函数jsVal(),其功能是:把千位数字和十位数字重新组成一个新的含有两位数字的数ab(新数的十位数字是原四位数的 ...

  7. Ubuntu 18.04 美化配置

    网上很多关于Ubuntu 18.04 美化的配置,但每个人遇见的问题都有些不太一样, 现将本人配置的过程整理如下 更新源为阿里云 找到Software & Updates,将源更新为阿里云的源 ...

  8. VueCLi3 配置less变量

    Step1. 文档介绍 // vue-cli css预处理文档: https://cli.vuejs.org/zh/guide/css.html#自动化导入 // less文档: https://ww ...

  9. 基于vue+leaflet+echart的足迹分享评论平台

    (其实题目是随便取的,目的只是用来证明Vue+leaflet+springboot技术栈的可行性) 效果 小专栏不支持上传视频?想看的话可以去我的知乎看最新的文章,那个应该可以.在这里 主要功能描述 ...

  10. zabbix服务深入

    第1章 Grafana自定义图形 1.安装grafana [root@m01 /data/soft]# wget https://dl.grafana.com/oss/release/grafana- ...