python抓包工具_使用fiddler工具进行抓包,使用python进行osc乱弹抢沙发

QiangShaFa

使用fiddler工具进行抓包,使用python进行osc乱弹抢沙发

查看乱弹列表 687474703a2f2f692e696d6775722e636f6d2f41636a5a37517a2e6a7067

使用fiddler抓包 687474703a2f2f692e696d6775722e636f6d2f663669727530732e6a7067 3.使用python beautifulsoup对返回的数据进行分析并分析如何判断最新乱弹的出现

flag=False

def hasnews(preid):

try:

global flag

ssl._create_default_https_context = ssl._create_unverified_context

import http.client,datetime

conn = http.client.HTTPSConnection('my.oschina.net')

conn.request("GET", "/xxiaobian/blog")

sourp=BeautifulSoup(conn.getresponse().read(),'lxml')

gilslist=sourp.find_all(class_='time')

import time

id=str(sourp.find_all(class_='blog-title',limit=1)[0]['href']).split('/')[-1]

if preid==None:

return id

if id!=str(preid):

return id

else:

print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+str(gilslist[0].get_text().strip().replace('发布','').strip()))

if flag:

print('sleep 2 second ...')

time.sleep(2)

else :

flag=True

date_str=datetime.datetime.now().strftime("%Y-%m-%d 23:40:50")

endtime=datetime.datetime.strptime(date_str,"%Y-%m-%d %H:%M:%S")

now=datetime.datetime.now()

print('endtime:{end} now:{now}'.format(end=endtime,now=now))

interval=(endtime-now)

sec = interval.days*24*3600 + interval.seconds

print('need sleep {second} second ...'.format(second=abs(sec)))

time.sleep(sec)

return None

except ValueError as e:

sendEmail('发生异常了!'+str(e))

fr=open('log.txt')

fr.write(str(e))

fr.close()

4.进行评论在fiddler中进行抓包 687474703a2f2f692e696d6775722e636f6d2f76515263446c522e6a7067 5.使用python进行请求发送

def qiangshafa(url):

ssl._create_default_https_context = ssl._create_unverified_context

#url = "https://my.oschina.net/action/blog/add_comment?blog=797134"

postdata =urllib.parse.urlencode({ "content":"今天是周一哈哈哈!" }).encode('utf-8')

header = {

"Accept": "application/json, text/javascript, */*; q=0.01",

"Origin": "https://my.oschina.net",

"X-Requested-With": "XMLHttpRequest",

"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",

"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",

"Referer":"https://my.oschina.net/xxiaobian/blog/844061?p=3&temp=1487827633938",

"Accept-Encoding": "gzip, deflate, br",

"Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",

"Cookie": "你的Cookie"}

req = urllib.request.Request(url,postdata,header)

print(urllib.request.urlopen(req).read().decode('utf-8'))

cj = http.cookiejar.CookieJar()

opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))

r = opener.open(req)

print(r.read().decode('utf-8'))

6.发送Email模块方便通知

def sendEmail(message):

from email.mime.text import MIMEText

msg = MIMEText(message, 'plain', 'utf-8')

from_addr = '13126506430@163.com'

password = '*******'

输入收件人地址:

to_addr = '13126506430@163.com'

输入SMTP服务器地址:

smtp_server = 'smtp.163.com'

import smtplib

server = smtplib.SMTP(smtp_server, 25) # SMTP协议默认端口是25

server.set_debuglevel(1)

server.login(from_addr, password)

server.sendmail(from_addr, [to_addr], msg.as_string())

server.quit()

7.运行

class log():

def __init__(self,id):

self.id=id

id=None

if __name__ == '__main__':

global id

import http.client,datetime, pickle,os

if os.path.exists('dump.txt'):

f = open('dump.txt', 'rb')

logid = pickle.load(f)

preid=logid.id

f.close()

print('preid is '+str(preid))

else:

preid=None

while id==None:

id = hasnews(preid)

f = open('dump.txt', 'wb')

pickle.dump(log(id), f)

f.close()

url="https://my.oschina.net/action/blog/add_comment?blog={id}".format(id=id)

qiangshafa(url)

sendEmail('over \t'+url+'\t'+str(datetime.datetime.now()))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值