# 1.导入必要的库 requests, BeautifulSoup,
import requests
from bs4 import BeautifulSoup
# 2.打开登录页,copy下来网址 https://www.chandashi.com/user/login.html
url = 'https://www.chandashi.com/user/login.html'
# 3.用Chrome开发工具查看提交表单需要的 key (username, password)
data = {'username' : 'xxx@qq.com', 'password' : 'xxx'}
# 4.用requests库post提交参数并取得提交参数后得到的cookies保存下来
r = requests.post(url, data=data)
print(r.cookies)
# 通过打印可以看到cookies的key是 cds_session_id
c_cookies = {'cds_session_id' : r.cookies['cds_session_id']}
# 5.打开某个打开任意一个app,copy下来地址 例如qq: https://www.chandashi.com/apps/keywordcover/appId/444934666/country/cn.html
url2 = 'https://www.chandashi.com/apps/keywordcover/appId/444934666/country/cn.html'
# 6.将上步保存下来的cookies添加到此次请求中可以得到此界面登录状态下的所有信息.
r2 = requests.get(url2, cookies = c_cookies).content
s1 = BeautifulSoup(r2, 'lxml')
# 打印本页面所有内容
print(s1)