• 点赞功能


    import requests
    
    def downLoad_img(url_para,file_path):
        img_get=requests.get(url=url_para)
        with open(file_path, 'wb') as f:
            f.write(img_get.content)  # 写入字节码
    util.py

    settings.py:

     USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'

    CHOUTI='https://dig.chouti.com/' 

    import requests,os
    from bs4 import BeautifulSoup
    import settings
    from chouti.utils.util import downLoad_img
    
    res=requests.get(
        url=settings.CHOUTI ,
        headers={
            'user-agent':settings.USER_AGENT
        }
    
    )
    soup=BeautifulSoup(res.text,'html.parser')
    
    item_list=soup.find_all(name='div',attrs={"id":'content-list'})
    for item in item_list:
        item_all = item.find_all(name='div', attrs={'class': 'item'})
        for item_obj in item_all:
            content_list=item_obj.find_all(name='div',attrs={'class':'news-content'})
            for content in content_list:
                href_list=content.find(name='a').attrs.get('href')
                share_pic=content.find(name='div',attrs={'class':'part2'})['share-pic']
                share_title=content.find(name='div',attrs={'class':'part2'})['share-title']
                summary=content.find(name='span').text
    
                print(href_list)
    
                img_name = share_pic.rsplit('/', maxsplit=1)[1]
                print(share_title)
                print(summary)
                file_path=os.path.join('chouti/imgs',img_name)
    
                # 下载图片
                downLoad_img(share_pic,file_path)
    
                # 写入文本
                with open('chouti/link.txt','a',encoding='utf-8') as linkf:
                    linkf.write(href_list+'
    ')
                    linkf.write(share_title+'
    ')
                    linkf.write(summary+'
    ')
    抽屉网
    """
    通过代码进行自动登录,然后进行点赞
    """
    import requests
    import settings
    
    # ##################### 第一部分:登录 #####################
    # 获取登录form页面
    r1 = requests.get(
        url='https://dig.chouti.com/',
        headers={
            'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
    } ) 
    r1_cookie_dict
    = r1.cookies.get_dict()

    print(r1_cookie_dict)
    # 提交账号-------------
    r2 = requests.post(
    url
    ='https://dig.chouti.com/login',
    headers
    ={ 'user-agent':settings.USER_AGENT },
    data
    ={ 'phone':'86'+'18310189881',
    'password':'abcd1234', 'oneMonth':1 },
    cookies
    =r1_cookie_dict ) print(r2.text)


      
    # # ##################### 第二部分:点赞 #####################
    r3 = requests.post(
    url
    ='https://dig.chouti.com/link/vote?linksId=20868591',
        

    headers
    ={ 'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' },
    cookies
    =r1_cookie_dict )
    print(r3.text)
  • 相关阅读:
    肯恩·威尔伯:整合灵性途径的几大障碍
    金刚经里面的「应无所住而生其心」,这句话怎么理解?
    成熟是人一辈子的修养,与年龄无关
    杰克·康菲尔德:灵性成熟的十个特质
    杰克·康菲尔德:我是谁?(强烈推荐)
    x11vnc:利用远程机器上的X-Server来进行VNC连接(x11vnc 和 x-server 在不同的机器上)
    Linux ALL:Tigervnc-Server
    Centos 6/Redhat 6:远程图形桌面: tigervnc
    Fedora 31 :远程图形桌面: tigervnc
    win server 2019 :【2个?远程管理用户(单会话?)】升级为远程桌面服务【多用户(多会话)】
  • 原文地址:https://www.cnblogs.com/wanghuaqiang/p/9325389.html
Copyright © 2020-2023  润新知