ich hab auch Python runtergeladen.
Aber wie ich aus dem Code eine Python "programm" mach, hab ich keine ahnung.
ich hoffe ihr könnt mir helfen.
villt macht ihr mirs sogar!?!
(ich weiß auch nicht wann der code losgeht.
das müsstet doch ihr am betsen wissen )
Code: Alles auswählen
#! /usr/bin/python
# (c) by evil in 2008
# there-is-an@evil-monkey-in-my-closet.com
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import twill,re,time
from twill.commands import *
PENNERNAME="<von Gerold entfernt>"
PASSWORT="<von Gerold entfernt>"
MAX_POINTS=200
SKIP_PETS=['Elefant','Tiger','Nashorn','Krokodil']
redirect_output('ptp.log')
class session:
def __init__(self):
# goto pennergame
self.b=twill.get_browser()
self.b.go("http://pennergame.de")
# login
fv(1,"username",PENNERNAME)
fv(1,"password",PASSWORT)
self.b.submit()
self.kick=[]
def action(self,n):
# go to pet fights
l=self.b.find_link('tierk')
self.b.follow_link(l)
lstr='/fight/pet/'+str(n)+'/'
l=self.b.find_link(lstr)
self.b.follow_link(l)
links=[]
l=showlinks()
for a in l:
links.append(a)
# setting up 20 link-grous
link_groups=[]
for x in range(0,links.__len__()):
tmp=[]
# looking for 'javascript:;'
link_str=str(links[x])
o=re.compile('javascript')
e=o.findall(link_str)
if e:
link_str=str(links[x+1])
o=re.compile('selbsterstelltes')
e=o.findall(link_str)
if e:
tmp.append(links[x:x+4])
x+=4
else:
tmp.append(links[x:x+3])
x+=3
link_groups.append(tmp)
n=2
for l in link_groups:
profil,pet,points,von=self.analyze(l[0])
if pet not in SKIP_PETS and points < MAX_POINTS and profil not in self.kick:
print "fight %s with %i -> # %s"%(pet,points,profil)
fv(n,"einsatz",str(von))
self.b.submit()
#check for success
text=self.b.get_html()
o1=re.compile('Die Herausforderung wurde abgeschickt!')
o2=re.compile('Das Passwort f.+r die Herausforderung ist falsch!')
o3=re.compile('Es l.+uft bereits eine Herausforderung zwischen euch.')
e1=o1.findall(text)
e2=o2.findall(text)
e3=o3.findall(text)
if e1:
print e1[0]
elif e2:
print e2[0]
elif e3:
print e3[0]
else:
pass#self.b.reload()
self.kick.append(profil)
self.b.back()
#self.b.reload()
#self.action()
n+=1
def analyze(self,link):
if link.__len__()==3:
link_str=str(link[0])
o=re.compile('text=\'(.*) vom')
e=o.findall(link_str)
pet = e[0]
else:
link_str=str(link[1])
o=re.compile('text=\'\[(.*)\] Bei')
e=o.findall(link_str)
pet =e[0]
link_str=str(link[0])
o=re.compile('Kampfpunkte: (\d+)')
e=o.findall(link_str)
points = e[0]
o=re.compile('xac(\d+)\.00-')
e=o.findall(link_str)
von = e[0]
link_str=str(link[-1])
o=re.compile('profil/(\d+)/\',')
e=o.findall(link_str)
profil = e[0]
return (profil,pet,int(points),int(von))
s=session()
n=1
while 1:
print "new action page "+str(n)
s.action(n)
n+=1
EDIT by gerold: Benutzername und Passwort aus dem Skript entfernt
.