• python request版 模拟登陆appAnnie


    # coding: utf-8
    import requests
    import re
    from bs4 import BeautifulSoup
    url = 'https://www.appannie.com/account/login/?_ref=header'

    session = requests.Session()
    session.headers['user-agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
    session.get(url)
    token = session.cookies.get('csrftoken')
    print(token)
    header = {
    "User-Agent": 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
    "Host": "www.appannie.com",
    'Connection': 'keep-alive',
    'Accept': 'application/json, text/plain,*/*',
    'Accept-Encoding': 'gzip, deflate, sdch',
    'Accept-Language': 'zh-CN,zh;q=0.8',
    'X-NewRelic-ID': 'VwcPUFJXGwEBUlJSDgc=',
    'X-Requested-With': 'XMLHttpRequest',
    }
    data = {
    'csrfmiddlewaretoken': token,
    'next': '/dashboard/home/',
    'username': '1@qq.com',
    'password': '1'
    }
    cookies = session.cookies
    r = session.post(url, data)
    #url_1 = "https://www.appannie.com/ajax/top-chart/table/?market=google-play&country_code=US&category=1&date=2018-12-26&rank_sorting_type=rank&page_size=100&order_type=desc"
    req_1 = session.get(url_1, headers=header, cookies=cookies)

    req_1.encoding = 'utf-8'
    content = req_1.text
    p1 = "apps/google-play/app/(.*?)/details/"
    pattern1 = re.compile(p1)
    print(pattern1.findall(content))

    下面数据是我自己想要的数据,你可以根据正则提取你自己想要的数据

    
    
  • 相关阅读:
    openpyxl python操作Excel表格,
    ansible剧本
    ansible基础知识(二)
    ansible基础知识
    Flask-Migrate
    Python3-笔记-B-003-数据结构-元组tuple( )
    Python3-笔记-B-002-数据结构-字典dict{ }
    Python3-笔记-B-001-数据结构-列表list[ ]
    Python3-笔记-A-001-基本语法
    cordova 学习链接
  • 原文地址:https://www.cnblogs.com/vinzen/p/10181342.html
Copyright © 2020-2023  润新知