import requests
class ChouTiSpider(object):
def __init__(self):
self.headers={
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:61.0) Gecko/20100101 Firefox/61.0",
"Host":"dig.chouti.com",
"Referer":"https://dig.chouti.com/",
"Cookie":"gpsd=8592bb5eb2e83ea146f026e160540c99; gpid=437c296938de4d34a83e5751eb7a81f4; JSESSIONID=aaahwOSmVfudyc09u4Atw; puid=1f758e3acf0f7b13e5d0eb66fc7d2367; puid=cdu_52992983314"
}
self.proxy={"http":"http://117.102.70.195:8080"}
self.session=requests.Session()
#定义一个函数模拟登陆抽屉网
def login(self):
post_url="https://dig.chouti.com/login"
data={
"oneMonth":"1",
"phone":"86自己的手机号",
"password":"自己的密码"
}
response=self.session.post(post_url,proxies=self.proxy,data=data,headers=self.headers).json()
print(response)
#定义一个点赞的函数
def dianzan(self):
response=self.session.post("https://dig.chouti.com/link/vote?linksId=21522206",proxies=self.proxy,headers=self.headers).text
print(response)
if __name__ == '__main__':
spider=ChouTiSpider()
spider.login()
spider.dianzan()