抽屉网自动点赞 评论

本人IP已被永久封停,慎用,慎爬

import requests
from bs4 import BeautifulSoup

headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
        }

base_url = 'https://dig.chouti.com/all/hot/recent/{}' # 1
for line in range(1, 121):
    index_url = base_url.format(line)

    index_res = requests.get(index_url, headers=headers)

    index_cookies = index_res.cookies

    #  <div class="part2" share-linkid="26332241" >
    soup = BeautifulSoup(index_res.text, 'lxml')
    div = soup.find_all(name='div', attrs={'class': 'part2'})
    for line in div:
        new_id = line.attrs['share-linkid']
        nice_url = 'https://dig.chouti.com/link/vote?linksId=%s' % new_id

        # 2.登录
        login_url = 'https://dig.chouti.com/login'

        data = {
                'phone': '8617329348372',
                'password': 'dyc13993657997',
                'oneMonth': '1'
        }
        login_res = requests.post(login_url, data=data, headers=headers, cookies=index_cookies)

        # 登录成功返回9999,登录失败访问主页
        '''
        {"result":{"code":"9999", "message":"", "data":{"complateReg":"0","destJid":"cdu_55906084308"}}}
        '''
        print(login_res.text)

        # 废弃
        login_cookies = login_res.cookies

        headers2 = {
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
            # referer必须填上一次发送请求的https://dig.chouti.com/all/hot/recent/1
            'referer': 'https://dig.chouti.com/all/hot/recent/1'
        }

        # list1 = ['tank1']

        # 3,点赞
        # cookies携带的是第一次发送请求的https://dig.chouti.com/all/hot/recent/1页面
        nice_res = requests.post(nice_url, headers=headers2, cookies=index_cookies)
        print(nice_res.text)


        # 4.评论
        # tank 到此一游
        # 请求url
        commit_url = 'https://dig.chouti.com/comments/create'

        commit_data = {
                'jid': 'cdu_55906084308',
                'linkId': new_id,
                'isAssent': "",
                'content': 'tank 到此一游',
                'sortType': 'score'
        }
        commit_res = requests.post(
            commit_url, headers=headers2, cookies=index_cookies, data=commit_data)

        print(commit_res.text)

        import time
        time.sleep(8)

  

posted @ 2019-06-25 21:04  优寒凌  阅读(174)  评论(0编辑  收藏  举报