爬虫之抽屉新热榜点赞基本示例

此处有一个注意事项   在第一次请求的时候 已经返回cookie



import requests
from bs4 import BeautifulSoup
#模拟首次打开
r0 = requests.get(
    url='http://dig.chouti.com/'
)
r0_cookie_dict = r0.cookies.get_dict()

#登陆请求  
r1 = requests.post(
    url='http://dig.chouti.com/login',
    data={
        'phone': '86' + '156xxxxx74',
        'password': 'xxxxx',
        'oneMonth': 1,

    },
    cookies = r0_cookie_dict
)
print(r1.text)
r1_cookie_dict=r1.cookies.get_dict()


#点赞请求
r2=requests.post(
    url='http://dig.chouti.com/link/vote?linksId=14796866',
    cookies=r0_cookie_dict
)


猜你喜欢

转载自blog.csdn.net/wuxingpu5/article/details/78297582