1 import requests,io,random,re
3 ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101'
5 HEADERS = {'user-agent': ua}
8 def __init__(self,url,user,password):
9 self.session=requests.session()
10 r=self.session.post(url+"login/",data={'username':user,'password':password,'auth-params':'login','submit':'Acceder','openid-url':''},headers=HEADERS)
11 if 'Login failed. Please check your credentials.' in r.text:
12 raise ValueError('Error con la contraseƱa o usuario')
16 self.password=password
17 def share(self,title,text):
18 r=self.session.post(self.url.replace('login/','')+'item/',data={\
23 ,'post_id_random':str(random.randint(1,100000000000))}\
25 if '<title>Forbidden</title>' in r.text:
28 raise ValueError('Error con la contraseƱa o usuario')
29 print(r.json,r.text,'gere')
30 def notifications(self,limit):
31 r=self.session.get(self.url+'/notifications/system',headers=HEADERS)
34 for i in re.findall('https://friendicarg.nsupdate.info/notification/.*',r.text):
39 out=out+'\n'+'\n'+i.replace(re.findall('"><img src=".*" aria-hidden="true" class="notif-image">',i)[0],' ').replace('<span class="notif-when">','').replace('</span></a>','')