import requests
from bs4 import BeautifulSoup
import json
python微信機器人。import time
#獲取文章ID
def get_title_id(page=10):
headers={
有趣的python小程序。'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'
}
note_id=[]
for i in range(1,page) :
python+appium自動化,url_zt='https://www.jianshu.com//c/vHz3Uc?order_by=added_at&page{}'.format(str(i))
html=requests.get(url_zt,headers=headers)
html.enconding='utf-8'
soup=BeautifulSoup(html.text,'html.parser')
用python自動發朋友圈?for s in soup.find_all('li',attrs{'data-note-id':True}):
print(s['data-note-id'])
note_id.append(s['data-note-id'])
print('插入一條id')
語法糖 python、return note_id
#點贊header設置
url='https://www.jianshu.com/'
headers={
簡書鉆有什么用,'method': 'POST',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36',
'accept': 'application/json',
'content-type': 'application/json; charset=UTF-8',
}
# 賬號cookie來自開發人員工具復制
cookies={
'cookie': 'sajssdk_2015_cross_new_user=1; __yadk_uid=wwpLCJ1JulEnbIrn0BOToiWKTYM4ZsA8; remember_user_token=W1sxOTA5OTE0Nl0sIiQyYSQxMSQ1eDJ3eUhJTHFKTTYxLmwwWVZIR3l1IiwiMTU2ODY0Mzc0Ni42NzEzNjQzIl0%3D--c8fe5fc79f81eb19bcbc93086e3cf0d5f0ceb1c8; _m7e_session_core=05a10cda75752a860ed093dbb9176187; read_mode=day; default_font=font2; locale=zh-CN; Hm_lvt_0c0e9d9b1e7d617b3e6842e85b9fb068=1568643708,1568643810,1568645105,1568647141; Hm_lpvt_0c0e9d9b1e7d617b3e6842e85b9fb068=1568647615; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2219099146%22%2C%22%24device_id%22%3A%2216d3a7376275b7-01baa090515039-36664c08-576000-16d3a73762d48%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%2C%22first_id%22%3A%2216d3a7376275b7-01baa090515039-36664c08-576000-16d3a73762d48%22%'
}
n=1 #計數器
#循環抓取頁面文章ID并以json方式發送
for note_id in get_title_id(50):
data={
'energy_point': '3',
'note_id': note_id,
}
#點贊鏈接拼接id
title_url=url+'shakespeare/notes/{}/like'.format(note_id)
print('休息一會兒~'+str(n))
time.sleep(5)
dianzan=requests.post(title_url,headers=headers,data=json.dumps(data),cookies=cookies)
print(dianzan.json())
n+=1
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态