我开发工具来自动化FB游戏中的一个点,但是因为我遇到了一个问题,我不是两天前的语法......但是我没有看到j或者'本来可以做错误。
如果有人看到比我更清楚的事情,找出实际上会有什么好处并且会帮助我突然继续我的项目。
- >这是一行:422
# File: j (Python 3.4)
import json
import urllib.request as urllib
import urllib.parse as urllib
import http.client as http
from urllib.error import URLError, HTTPError
import time
import hashlib
import sys
dragon_heart = 'xxx'
session_id = 'xxx'
user_id = xxx
realm_number = 1
c = 1
server = 'realm{}.c{}.castle.rykaiju.com'.format(realm_number, c)
cookie = '__utma=54346615.1735014085.1418478784.1420098297.1420260161.37; __utmc=54346615; __utmz=54346615.1420260161.37.36.utmcsr=castle.wonderhill.com|utmccn=(referral)|utmcmd=referral|utmcct=/platforms/kabam; __utmt_~49=1; __utmt_~50=1; __utmt_~51=1; __utma=109650694.1096652092.1418485402.1420282135.1420308691.91; __utmb=109650694.6.10.1420308691; __utmc=109650694; __utmz=109650694.1420308691.91.91.utmcsr=castle.wonderhill.com|utmccn=(referral)|utmcmd=referral|utmcct=/platforms/kabam; dragons={}'.format(session_id)
version = 'overarch'
stdparams = 'dragon%5Fheart={0}&user%5Fid={1}&version={2}&%5Fsession%5Fid={3}&%5Fmethod=get'.format(dragon_heart, user_id, version, session_id)
realm = 'realm{0}.c{1}.castle.rykaiju.com'.format(realm_number, c)
location = ''
Ttype = ''
speedyn = 0
job_id = 0
operation_list = [
'player',
'general',
'forge']
def clear_screen(header1, subheader1 = ''):
import os
if os.name == 'nt':
pass
1('clear')
print('\n' + header1)
print('\n' + subheader1)
ul = '=' * 79
print('\n{0}\n'.format(ul))
def status(operation):
url = 'http://%s/api/%s.json' % (server, operation)
i = 0
success = False
while success == False:
if i >= 7:
print('Something is wrong, please check idle, resources, speeds, queues, and internet connection. Exiting...')
time.sleep(3)
sys.exit(0)
params = '?' + stdparams + '×tamp=' + str(int(time.time()))
response = urllib.request.urlopen(url + params)
try:
response_json = json.loads(response.read().decode('utf8'))
except UnicodeDecodeError:
e = None
try:
print('Invalid response from server: Check your realm variables entered.')
time.sleep(3)
sys.exit(0)
finally:
e = None
del e
except KeyError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except ValueError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except HTTPError:
e = None
try:
print('Invalid response from server: Check your realm variables entered.')
time.sleep(3)
sys.exit(0)
finally:
e = None
del e
try:
success = response_json['result']['success']
if success == False:
try:
n = 0
while n < len(response_json['result']['errors']):
print(response_json['result']['errors'][n])
n += 1
except KeyError:
e = None
try:
print('Failed, retrying...')
finally:
e = None
del e
except ValueError:
e = None
try:
print('Failed, retrying...')
finally:
e = None
del e
time.sleep(2)
except KeyError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except ValueError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except UnboundLocalError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
if operation in operation_list:
return response_json
None += 1
return response_json
req = status('player')
capital_id = req['cities']['capital']['id']
location = 'spectral'
location = req['cities'][location]['id']
locationcap = capital_id
def myajax(realm, url, params, cookie, method = 'POST'):
commandstring = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
encodedcommandstring = commandstring.encode('utf8')
shaofencodedcommandstring = hashlib.sha1(encodedcommandstring).hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': shaofencodedcommandstring,
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0',
'content-type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request(method, url, params, headers)
response = conn.getresponse()
try:
jsondata = json.loads(response.read().decode('utf8'))
except:
print(response)
sys.exit()
conn.close()
return jsondata
built = 0
blue_ene = 0
bluecheck = 0
print("Welcome to Fruit Loops' Auto Revive / clone Script")
print(50 * '*')
time.sleep(1)
print('\nThis Script preserves BE Glitch\n===============================')
time.sleep(1)
print('\nTroops available for reviving:\n==============================')
print('1. Arctic Leviathan 2. Battle Dragon 3. Dragon Rider')
print('4. Sand Strider 5. Fire Mirror 6. Giants')
print('7: Pack Dragon 8. Dimensional R. 9. Soul Reaper')
print('10:Fangtooth 11.Granite Ogre 12.Lava Jaw')
print('13:Banshee 14.Frost Giant 15.Petrified Titan')
print('16:Venom Dweller 17.Lightning C. 18.Storm Drake')
print('19.Venge Wyrm')
troop = int(input('\nEnter TROOP you want to Revive(number):'))
print(40 * '=')
print('Coords to attack:\n')
coordx = int(input('Enter X coord(Coo):'))
coordy = int(input('Enter Y coord(Coo):'))
while blue_ene <= 0 or blue_ene % 15 != 0:
if bluecheck > 1:
print('You have entered invalied number for BE\n')
print(39 * '=')
blue_ene = int(input('\nEnter your Blue Energy Amount:'))
bluecheck = bluecheck + 1
if bluecheck == 10:
print('BE must give round number when divided by 15!! Ex: 6 750 000/15=450 000')
sys.exit()
continue
build = int(input('Enter No. of BATCHES to do:'))
print(79 * '=')
if troop == 1:
Ttype = 'ArcticLeviathan'
number = round(blue_ene / 15)
name = 'Arctic Leviathan'
power = 15
if troop == 2:
Ttype = 'BattleDragon'
number = round(blue_ene / 10)
name = 'Battle Dragon'
power = 7
if troop == 3:
Ttype = 'DragonRider'
number = round(blue_ene / 15)
name = 'Dragon Rider'
power = 75
if troop == 4:
Ttype = 'DesertTroop'
number = round(blue_ene / 15)
name = 'Sand Strider'
power = 10
if troop == 5:
Ttype = 'FireMirror'
number = round(blue_ene / 10)
name = 'Fire Mirror'
power = 10
if troop == 6:
Ttype = 'Giant'
number = round(blue_ene / 10)
name = Ttype
power = 9
if troop == 7:
Ttype = 'PackDragon'
number = round(blue_ene / 15)
name = 'Pack Dragon'
power = 6
if troop == 8:
Ttype = 'DimensionalRuiner'
number = round(blue_ene / 15)
name = 'Dimensional Ruiner'
power = 35
if troop == 9:
Ttype = 'IceTroop'
number = round(blue_ene / 15)
name = 'Soul Reaper'
power = 10
if troop == 10:
Ttype = 'AquaTroop'
number = round(blue_ene / 15)
name = 'Fangtooth'
power = 10
if troop == 11:
Ttype = 'StoneTroop'
number = round(blue_ene / 15)
name = 'Granite Ogre'
power = 9
if troop == 12:
Ttype = 'FireTroop'
number = round(blue_ene / 15)
name = 'Lava Jaw'
power = 8
if troop == 13:
Ttype = 'WindTroop'
number = round(blue_ene / 15)
name = 'Banshee'
power = 6
if troop == 14:
Ttype = 'FrostGiant'
number = round(blue_ene / 15)
name = 'Frost Giant'
power = 8
if troop == 15:
Ttype = 'ForestTroop'
number = round(blue_ene / 15)
name = 'Petrified Titan'
power = 20
if troop == 16:
Ttype = 'SwampTroop'
number = round(blue_ene / 15)
name = 'Venom Dweller'
power = 9
if troop == 17:
Ttype = 'LightningCannon'
number = round(blue_ene / 15)
name = 'Lightning Cannon'
power = 10
if troop == 18:
Ttype = 'ChargeTroop'
number = round(blue_ene / 15)
name = 'Storm Drake'
power = 10
if troop == 19:
Ttype = 'VengeWyrm'
number = round(blue_ene / 15)
name = 'Venge Wyrm'
power = 10
generals = list()
params = 'dragon%%5Fheart=%s×tamp=%d&version=overarch&%%5Fsession%%5Fid=%s&user%%5Fid=%d' % (dragon_heart, int(time.time()), session_id, user_id)
url = 'http://%s/api/cities/%s.json' % (realm, capital_id)
jsonData = myajax(realm, url, params, cookie)
for x in range(0, len(jsonData['city']['generals'])):
generals.insert(x, jsonData['city']['generals'][x]['id'])
general1 = generals[6]
general2 = generals[1]
general3 = generals[2]
print('\nITEMS TO BE USED:')
if not input('\nEnter No. of Dark Testronius Infusions to use: '):
pass
infu = int(0)
if not input('Enter No. of Dark Testronius Deluxes to use: '):
pass
deluxe = int(0)
if not input('Enter No. of Jumps (1h) to use: '):
pass
jump = int(0)
if not input('Enter No. of Leaps (2.5h) to use: '):
pass
leap = int(0)
if not input('Enter No. of Bounces (8h) to use: '):
pass
bounce = int(0)
if not input('Enter No. of Bores (15h) to use: '):
pass
bore = int(0)
if not input('Enter No. of Bolts (24h) to use: '):
pass
bolt = int(0)
if not input('Enter No. of Blast (2.5d) to use: '):
pass
blast = int(0)
if not input('Enter No. of Blitzes (4d) to use: '):
pass
blitz = int(0)
print('\n')
print(79 * '=')
all = jump + leap * 2.5 + bounce * 8 + bore * 15 + bolt * 24 + blast * 60 + blitz * 96
minonumber = number + 250000
input('\nPress ENTER to start...')
header = 'AUTO TRANSFORMING'
clear_screen(header)
start_time = time.time()
for x in range(0, build):
print('\n')
print(79 * '=')
print('\nSending Attack')
print('==============')
t = time.time()
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&march%5Bx%5D={2}&march%5Bmarch%5Ftype%5D=attack×tamp={3}&%5Fsession%5Fid={4}&march%5Bgeneral%5Fid%5D={5}&march%5Bunits%5D=%7B%22{6}%22%3A1%2C%22Minotaur%22%3A{7}%7D&%5Fmethod=post&march%5By%5D={8}&version=overarch'.format(user_id, dragon_heart, coordx, int(time.time()), session_id, general1, Ttype, minonumber, coordy)
url = 'http://realm{}.c{}.castle.rykaiju.com/api/cities/{}/marches.json'.format(realm_number, c, locationcap)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
time.sleep(0.5)
response = conn.getresponse()
responseData = response.read().decode('utf-8')
items = json.loads(responseData)
Duration = items['result']['job']['duration']
print('\nWaiting for attack to hit.')
time.sleep(Duration)
print('\nWaiting for Spectral outpost to update')
time.sleep(15)
checkup = 0
while checkup == 0:
try:
params = '{0}&%5Fmethod={1}'.format(stdparams, 'put')
url = 'http://%s/api/cities/%s.json' % (realm, capital_id)
jsondata = myajax(realm, url, params, cookie)
checkup = len(jsondata['city']['souls'])
continue
continue
continue
datat = jsondata['city']['souls'][Ttype]
datat = int(datat)
if checkup > 1:
datam = jsondata['city']['souls']['Minotaur']
datam = int(datam)
build1 = int(datat / number)
datatr = int(datat - build1 * number)
Ex = 0
if build1 < 1:
if datat > 1 * number:
build1 = 1
if datat > 2 * number:
build1 = 2
if datat > 3 * number:
build1 = 3
print('\nAuto Reviving')
print('=============')
for kj in range(0, build1):
while job_id == 0:
try:
time.sleep(4)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={}&dragon%5Fheart={}×tamp={}&%5Fsession%5Fid={}&units%5Bunit%5Ftype%5D={}&units%5Bquantity%5D={}&%5Fmethod=post&version=overarch'.format(user_id, dragon_heart, int(time.time()), session_id, Ttype, number)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/resurrect.json'.format(realm_number, c, location)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
response = conn.getresponse()
responseData = response.read().decode('utf-8')
items = json.loads(responseData)
idValue = items['result']['job']['id']
job_id = idValue
runat = items['result']['job']['run_at']
timestamp = items['timestamp']
continue
continue
continue
print('\nReviving: ', number, ' ', Ttype, '\n')
Atestro = 0
testro = 0
timeleft = (runat - timestamp) / 3600
while timeleft > all:
timeleft = timeleft * 0.7
Atestro = Atestro + 1
time.sleep(0.1)
testro = Atestro - infu * 13 - deluxe * 2
if testro < 0:
testro = 0
objects = [
{
'object': 'DarkTestroniusInfusion',
'quantity': infu },
{
'object': 'DarkTestroniusDeluxe',
'quantity': deluxe },
{
'object': 'DarkTestroniusPowder',
'quantity': testro },
{
'object': 'Blitz',
'quantity': blitz },
{
'object': 'Blast',
'quantity': blast },
{
'object': 'Bolt',
'quantity': bolt },
{
'object': 'Bore',
'quantity': bore },
{
'object': 'Bounce',
'quantity': bounce },
{
'object': 'Leap',
'quantity': leap },
{
'object': 'Jump',
'quantity': jump }]
time.sleep(5)
for obj in objects:
item = obj['object']
qty = obj['quantity']
if qty != 0:
qtyNo = 0
while qtyNo != qty:
try:
time.sleep(1)
params = '{0}&job%5Fid={1}×tamp={2}&%5Fmethod={3}'.format(stdparams, job_id, int(time.time()), 'delete')
url = 'http://%s/api/player_items/%s.json' % (realm, item)
jsondata = myajax(realm, url, params, cookie)
result = jsondata['result']['success']
print('Using: ', item)
qtyNo = qtyNo + 1
safety = 'DarkTestroniusPowder'
if safety == item:
runat = jsondata['result']['item_response']['run_at']
timestamp = jsondata['timestamp']
timeleft = (runat - timestamp) / 3600
if timeleft > all:
qtyNo = qtyNo - 1
if timeleft < all:
qtyNo = qty
time.sleep(0.5)
continue
continue
continue
continue
time.sleep(2)
job_id = 0
built = built + 1
build1 = 0
kj = 0
if checkup > 1:
time.sleep(3)
time.sleep(1)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&units%5Bquantity%5D={2}×tamp={3}&%5Fsession%5Fid={4}&units%5Bunit%5Ftype%5D=Minotaur&%5Fmethod=delete&version=overarch'.format(user_id, dragon_heart, datam, int(time.time()), session_id)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/release.json'.format(realm_number, c, capital_id)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
print('\nReleasing remaining mino')
time.sleep(1)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&units%5Bquantity%5D={2}×tamp={3}&%5Fsession%5Fid={4}&units%5Bunit%5Ftype%5D={5}&%5Fmethod=delete&version=overarch'.format(user_id, dragon_heart, datatr, int(time.time()), session_id, Ttype)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/release.json'.format(realm_number, c, capital_id)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
print('\nReleasing remaining: ', name)
print('\nNumber of BATCHES done: ', built)
print('***********************\nItems used:')
print('===========')
if testro != 0:
print('Dark Testronius Powder: ', testro * built)
if deluxe != 0:
print('Dark Testronius Deluxe: ', deluxe * built)
if infu != 0:
print('Dark Testronius Infusion: ', infu * built)
if jump != 0:
print('Jump: ', jump * built)
if leap != 0:
print('Leap: ', leap * built)
if bounce != 0:
print('Bounce: ', bounce * built)
if bore != 0:
print('Bore: ', bore * built)
if bolt != 0:
print('Bolt: ', boltbr)
if blast != 0:
print('Blast: ', blast * built)
if blitz != 0:
print('Blitz: ', blitz * built)
if build > 1 and build != built:
print('\nWaiting for generals...')
time.sleep(10)
time.sleep(Duration)
totalpower = number * built * power
elapsed_time = time.time() - start_time
print(79 * '=')
print('\nElapsed time: {0}'.format(time.strftime('%H:%M:%S', time.gmtime(elapsed_time))))
print('\n\nRevived {0} of {1} in total power of {2}'.format(format(number * built, ',d'), name, format(totalpower, ',d')))
print('\nReviving completed!!\n')
print(79 * '=')
input('Press Enter to Exit...')
提前感谢您的协助。
此致 highboy
答案 0 :(得分:1)
当您在python中编写using Microsoft.AspNet.Html.Abstractions;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Mvc.ViewFeatures.Internal;
using Microsoft.Extensions.WebEncoders;
using System.ComponentModel.DataAnnotations;
using System;
public class MyController : Controller
{
private readonly IHtmlGenerator htmlGenerator;
ICompositeViewEngine viewEngine;
IModelMetadataProvider metadataProvider;
private readonly IHtmlHelper helper;
IHtmlEncoder htmlEncoder;
IUrlEncoder urlEncoder;
IJavaScriptStringEncoder javaScriptStringEncoder;
public MyController(IHtmlHelper helper, IHtmlGenerator htmlGenerator, ICompositeViewEngine viewEngine, IModelMetadataProvider metadataProvider, IHtmlEncoder htmlEncoder, IUrlEncoder urlEncoder, IJavaScriptStringEncoder javaScriptStringEncoder)
{
this.htmlGenerator = htmlGenerator;
this.viewEngine = viewEngine;
this.metadataProvider = metadataProvider;
this.htmlEncoder = htmlEncoder;
this.urlEncoder = urlEncoder;
this.javaScriptStringEncoder = javaScriptStringEncoder;
this.helper = helper;
}
[HttpGet]
public IActionResult MyHtmlGenerator()
{
MyViewModel temp = new MyViewModel();
var options = new HtmlHelperOptions();
options.ClientValidationEnabled = true;
ViewDataDictionary<MyViewModel> dic = new ViewDataDictionary<MyViewModel>(this.metadataProvider, new ModelStateDictionary());
ViewContext cc = new ViewContext(ActionContext, new FakeView(), dic, TempData, TextWriter.Null, options);
var type = typeof(MyViewModel);
var metadata = this.metadataProvider.GetMetadataForType(type);
ModelExplorer modelEx = new ModelExplorer(this.metadataProvider, metadata, temp);
ViewData["Description"] = "test desc";
ViewData["Id"] = 1;
this.ViewData = new ViewDataDictionary(this.metadataProvider, new ModelStateDictionary());
IHtmlHelper<MyViewModel> dd = new HtmlHelper<MyViewModel>(this.htmlGenerator, this.viewEngine, this.metadataProvider, this.htmlEncoder, this.urlEncoder, this.javaScriptStringEncoder);
((ICanHasViewContext)dd).Contextualize(cc);
dd.ViewContext.ViewData = this.ViewData;
var desc = GetString(dd.TextBoxFor(m => m.ID));
var ID = GetString(dd.TextBoxFor(m => m.Description));
// Do whatever you want with the ID and desc
return new ContentResult() { Content = ID + desc };
}
public static string GetString(IHtmlContent content)
{
var writer = new System.IO.StringWriter();
content.WriteTo(writer, new HtmlEncoder());
return writer.ToString();
}
}
public class MyViewModel : BaseAssetViewModel
{
// [RegularExpression(@"^-?\d{1,13}(\.\d{0,5})?$|^-?\.\d{1,5}$")]
[Required]
public int ID { get; set; }
[MinLength(2)]
public string Description { get; set; }
// Property with no validation
public string Other { get; set; }
}
public class FakeView : IView
{
string IView.Path
{
get
{
throw new NotImplementedException();
}
}
public Task RenderAsync(ViewContext viewContext)
{
throw new InvalidOperationException();
}
Task IView.RenderAsync(ViewContext context)
{
throw new NotImplementedException();
}
}
语句时,必须后跟try
语句,如果您希望程序在发生错误时不执行任何操作,则只需在except
之后添加except:pass
尝试:
#code before
try:
#this might raise an error
except:pass
#keep going with other stuff
靠近文件顶部
user_id = xxx
这将引发名称错误,因为xxx被视为变量而不是上面3行的字符串,我强烈建议更频繁地测试程序以排除相当微不足道的错误。
答案 1 :(得分:0)
我还看到了一些其他问题:
import urllib.request as urllib
import urllib.parse as urllib
第二个导入会覆盖第一个导入,您无法调用urllib.request
。
1('clear')
......真的吗?这是一个语法错误;我认为您的意思是os.system('clear')
,或os.system('cls')
os.system == 'nt'
(不是pass
)。
round
并非真的有必要,即
number = round(blue_ene / 15)
可以使用整数除法
number = blue_ene // 15 # gives int, assuming blue_ene is int
if
s(第235-329行)的长级联可以用一个合适的数据结构替换,即整数的dict:TroopType。
答案 2 :(得分:0)
是的,我编辑了Hugh Bothwell的所有错误(谢谢)。
但是,已经出现同样的问题,错误语法@ line 422 ..
# File: j (Python 3.4)
import json
import urllib.request as urllib
import urllib.parse as urllib
import http.client as http
from urllib.error import URLError, HTTPError
import time
import hashlib
import sys
dragon_heart = 'xxx'
session_id = 'xxx'
user_id = 111
realm_number = 222
c = 333
server = 'realm{}.c{}.castle.rykaiju.com'.format(realm_number, c)
cookie = '__utma=54346615.1735014085.1418478784.1420098297.1420260161.37; __utmc=54346615; __utmz=54346615.1420260161.37.36.utmcsr=castle.wonderhill.com|utmccn=(referral)|utmcmd=referral|utmcct=/platforms/kabam; __utmt_~49=1; __utmt_~50=1; __utmt_~51=1; __utma=109650694.1096652092.1418485402.1420282135.1420308691.91; __utmb=109650694.6.10.1420308691; __utmc=109650694; __utmz=109650694.1420308691.91.91.utmcsr=castle.wonderhill.com|utmccn=(referral)|utmcmd=referral|utmcct=/platforms/kabam; dragons={}'.format(session_id)
version = 'overarch'
stdparams = 'dragon%5Fheart={0}&user%5Fid={1}&version={2}&%5Fsession%5Fid={3}&%5Fmethod=get'.format(dragon_heart, user_id, version, session_id)
realm = 'realm{0}.c{1}.castle.rykaiju.com'.format(realm_number, c)
location = ''
Ttype = ''
speedyn = 0
job_id = 0
operation_list = [
'player',
'general',
'forge']
def clear_screen(header1, subheader1 = ''):
import os
if os.name == 'nt':
pass
os.system('clear')
print('\n' + header1)
print('\n' + subheader1)
ul = '=' * 79
print('\n{0}\n'.format(ul))
def status(operation):
url = 'http://%s/api/%s.json' % (server, operation)
i = 0
success = False
while success == False:
if i >= 7:
print('Something is wrong, please check idle, resources, speeds, queues, and internet connection. Exiting...')
time.sleep(3)
sys.exit(0)
params = '?' + stdparams + '×tamp=' + str(int(time.time()))
response = urllib.request.urlopen(url + params)
try:
response_json = json.loads(response.read().decode('utf8'))
except UnicodeDecodeError:
e = None
try:
print('Invalid response from server: Check your realm variables entered.')
time.sleep(3)
sys.exit(0)
finally:
e = None
del e
except KeyError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except ValueError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except HTTPError:
e = None
try:
print('Invalid response from server: Check your realm variables entered.')
time.sleep(3)
sys.exit(0)
finally:
e = None
del e
try:
success = response_json['result']['success']
if success == False:
try:
n = 0
while n < len(response_json['result']['errors']):
print(response_json['result']['errors'][n])
n += 1
except KeyError:
e = None
try:
print('Failed, retrying...')
finally:
e = None
del e
except ValueError:
e = None
try:
print('Failed, retrying...')
finally:
e = None
del e
time.sleep(2)
except KeyError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except ValueError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
except UnboundLocalError:
e = None
try:
success = False
time.sleep(2)
finally:
e = None
del e
if operation in operation_list:
return response_json
None += 1
return response_json
req = status('player')
capital_id = req['cities']['capital']['id']
location = 'spectral'
location = req['cities'][location]['id']
locationcap = capital_id
def myajax(realm, url, params, cookie, method = 'POST'):
commandstring = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
encodedcommandstring = commandstring.encode('utf8')
shaofencodedcommandstring = hashlib.sha1(encodedcommandstring).hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': shaofencodedcommandstring,
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0',
'content-type': 'application/x-www-form-urlencoded',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request(method, url, params, headers)
response = conn.getresponse()
try:
jsondata = json.loads(response.read().decode('utf8'))
except:
print(response)
sys.exit()
conn.close()
return jsondata
built = 0
blue_ene = 0
bluecheck = 0
print("Welcome to Fruit Loops' Auto Revive / clone Script")
print(50 * '*')
time.sleep(1)
print('\nThis Script preserves BE Glitch\n===============================')
time.sleep(1)
print('\nTroops available for reviving:\n==============================')
print('1. Arctic Leviathan 2. Battle Dragon 3. Dragon Rider')
print('4. Sand Strider 5. Fire Mirror 6. Giants')
print('7: Pack Dragon 8. Dimensional R. 9. Soul Reaper')
print('10:Fangtooth 11.Granite Ogre 12.Lava Jaw')
print('13:Banshee 14.Frost Giant 15.Petrified Titan')
print('16:Venom Dweller 17.Lightning C. 18.Storm Drake')
print('19.Venge Wyrm')
troop = int(input('\nEnter TROOP you want to Revive(number):'))
print(40 * '=')
print('Coords to attack:\n')
coordx = int(input('Enter X coord(Coo):'))
coordy = int(input('Enter Y coord(Coo):'))
while blue_ene <= 0 or blue_ene % 15 != 0:
if bluecheck > 1:
print('You have entered invalied number for BE\n')
print(39 * '=')
blue_ene = int(input('\nEnter your Blue Energy Amount:'))
bluecheck = bluecheck + 1
if bluecheck == 10:
print('BE must give round number when divided by 15!! Ex: 6 750 000/15=450 000')
sys.exit()
continue
build = int(input('Enter No. of BATCHES to do:'))
print(79 * '=')
if troop == 1:
Ttype = 'ArcticLeviathan'
number = round(blue_ene / 15)
name = 'Arctic Leviathan'
power = 15
if troop == 2:
Ttype = 'BattleDragon'
number = round(blue_ene / 10)
name = 'Battle Dragon'
power = 7
if troop == 3:
Ttype = 'DragonRider'
number = round(blue_ene / 15)
name = 'Dragon Rider'
power = 75
if troop == 4:
Ttype = 'DesertTroop'
number = round(blue_ene / 15)
name = 'Sand Strider'
power = 10
if troop == 5:
Ttype = 'FireMirror'
number = round(blue_ene / 10)
name = 'Fire Mirror'
power = 10
if troop == 6:
Ttype = 'Giant'
number = round(blue_ene / 10)
name = Ttype
power = 9
if troop == 7:
Ttype = 'PackDragon'
number = round(blue_ene / 15)
name = 'Pack Dragon'
power = 6
if troop == 8:
Ttype = 'DimensionalRuiner'
number = round(blue_ene / 15)
name = 'Dimensional Ruiner'
power = 35
if troop == 9:
Ttype = 'IceTroop'
number = round(blue_ene / 15)
name = 'Soul Reaper'
power = 10
if troop == 10:
Ttype = 'AquaTroop'
number = round(blue_ene / 15)
name = 'Fangtooth'
power = 10
if troop == 11:
Ttype = 'StoneTroop'
number = round(blue_ene / 15)
name = 'Granite Ogre'
power = 9
if troop == 12:
Ttype = 'FireTroop'
number = round(blue_ene / 15)
name = 'Lava Jaw'
power = 8
if troop == 13:
Ttype = 'WindTroop'
number = round(blue_ene / 15)
name = 'Banshee'
power = 6
if troop == 14:
Ttype = 'FrostGiant'
number = round(blue_ene / 15)
name = 'Frost Giant'
power = 8
if troop == 15:
Ttype = 'ForestTroop'
number = round(blue_ene / 15)
name = 'Petrified Titan'
power = 20
if troop == 16:
Ttype = 'SwampTroop'
number = round(blue_ene / 15)
name = 'Venom Dweller'
power = 9
if troop == 17:
Ttype = 'LightningCannon'
number = round(blue_ene / 15)
name = 'Lightning Cannon'
power = 10
if troop == 18:
Ttype = 'ChargeTroop'
number = round(blue_ene / 15)
name = 'Storm Drake'
power = 10
if troop == 19:
Ttype = 'VengeWyrm'
number = round(blue_ene / 15)
name = 'Venge Wyrm'
power = 10
generals = list()
params = 'dragon%%5Fheart=%s×tamp=%d&version=overarch&%%5Fsession%%5Fid=%s&user%%5Fid=%d' % (dragon_heart, int(time.time()), session_id, user_id)
url = 'http://%s/api/cities/%s.json' % (realm, capital_id)
jsonData = myajax(realm, url, params, cookie)
for x in range(0, len(jsonData['city']['generals'])):
generals.insert(x, jsonData['city']['generals'][x]['id'])
general1 = generals[6]
general2 = generals[1]
general3 = generals[2]
print('\nITEMS TO BE USED:')
if not input('\nEnter No. of Dark Testronius Infusions to use: '):
pass
infu = int(0)
if not input('Enter No. of Dark Testronius Deluxes to use: '):
pass
deluxe = int(0)
if not input('Enter No. of Jumps (1h) to use: '):
pass
jump = int(0)
if not input('Enter No. of Leaps (2.5h) to use: '):
pass
leap = int(0)
if not input('Enter No. of Bounces (8h) to use: '):
pass
bounce = int(0)
if not input('Enter No. of Bores (15h) to use: '):
pass
bore = int(0)
if not input('Enter No. of Bolts (24h) to use: '):
pass
bolt = int(0)
if not input('Enter No. of Blast (2.5d) to use: '):
pass
blast = int(0)
if not input('Enter No. of Blitzes (4d) to use: '):
pass
blitz = int(0)
print('\n')
print(79 * '=')
all = jump + leap * 2.5 + bounce * 8 + bore * 15 + bolt * 24 + blast * 60 + blitz * 96
minonumber = number + 250000
input('\nPress ENTER to start...')
header = 'AUTO TRANSFORMING'
clear_screen(header)
start_time = time.time()
for x in range(0, build):
print('\n')
print(79 * '=')
print('\nSending Attack')
print('==============')
t = time.time()
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&march%5Bx%5D={2}&march%5Bmarch%5Ftype%5D=attack×tamp={3}&%5Fsession%5Fid={4}&march%5Bgeneral%5Fid%5D={5}&march%5Bunits%5D=%7B%22{6}%22%3A1%2C%22Minotaur%22%3A{7}%7D&%5Fmethod=post&march%5By%5D={8}&version=overarch'.format(user_id, dragon_heart, coordx, int(time.time()), session_id, general1, Ttype, minonumber, coordy)
url = 'http://realm{}.c{}.castle.rykaiju.com/api/cities/{}/marches.json'.format(realm_number, c, locationcap)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
time.sleep(0.5)
response = conn.getresponse()
responseData = response.read().decode('utf-8')
items = json.loads(responseData)
Duration = items['result']['job']['duration']
print('\nWaiting for attack to hit.')
time.sleep(Duration)
print('\nWaiting for Spectral outpost to update')
time.sleep(15)
checkup = 0
while checkup == 0:
try:
params = '{0}&%5Fmethod={1}'.format(stdparams, 'put')
url = 'http://%s/api/cities/%s.json' % (realm, capital_id)
jsondata = myajax(realm, url, params, cookie)
checkup = len(jsondata['city']['souls'])
continue
datat = jsondata['city']['souls'][Ttype]
datat = int(datat)
if checkup > 1:
datam = jsondata['city']['souls']['Minotaur']
datam = int(datam)
build1 = int(datat / number)
datatr = int(datat - build1 * number)
Ex = 0
if build1 < 1:
if datat > 1 * number:
build1 = 1
if datat > 2 * number:
build1 = 2
if datat > 3 * number:
build1 = 3
print('\nAuto Reviving')
print('=============')
for kj in range(0, build1):
while job_id == 0:
try:
time.sleep(4)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={}&dragon%5Fheart={}×tamp={}&%5Fsession%5Fid={}&units%5Bunit%5Ftype%5D={}&units%5Bquantity%5D={}&%5Fmethod=post&version=overarch'.format(user_id, dragon_heart, int(time.time()), session_id, Ttype, number)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/resurrect.json'.format(realm_number, c, location)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
response = conn.getresponse()
responseData = response.read().decode('utf-8')
items = json.loads(responseData)
idValue = items['result']['job']['id']
job_id = idValue
runat = items['result']['job']['run_at']
timestamp = items['timestamp']
continue
continue
continue
print('\nReviving: ', number, ' ', Ttype, '\n')
Atestro = 0
testro = 0
timeleft = (runat - timestamp) / 3600
while timeleft > all:
timeleft = timeleft * 0.7
Atestro = Atestro + 1
time.sleep(0.1)
testro = Atestro - infu * 13 - deluxe * 2
if testro < 0:
testro = 0
objects = [
{
'object': 'DarkTestroniusInfusion',
'quantity': infu },
{
'object': 'DarkTestroniusDeluxe',
'quantity': deluxe },
{
'object': 'DarkTestroniusPowder',
'quantity': testro },
{
'object': 'Blitz',
'quantity': blitz },
{
'object': 'Blast',
'quantity': blast },
{
'object': 'Bolt',
'quantity': bolt },
{
'object': 'Bore',
'quantity': bore },
{
'object': 'Bounce',
'quantity': bounce },
{
'object': 'Leap',
'quantity': leap },
{
'object': 'Jump',
'quantity': jump }]
time.sleep(5)
for obj in objects:
item = obj['object']
qty = obj['quantity']
if qty != 0:
qtyNo = 0
while qtyNo != qty:
try:
time.sleep(1)
params = '{0}&job%5Fid={1}×tamp={2}&%5Fmethod={3}'.format(stdparams, job_id, int(time.time()), 'delete')
url = 'http://%s/api/player_items/%s.json' % (realm, item)
jsondata = myajax(realm, url, params, cookie)
result = jsondata['result']['success']
print('Using: ', item)
qtyNo = qtyNo + 1
safety = 'DarkTestroniusPowder'
if safety == item:
runat = jsondata['result']['item_response']['run_at']
timestamp = jsondata['timestamp']
timeleft = (runat - timestamp) / 3600
if timeleft > all:
qtyNo = qtyNo - 1
if timeleft < all:
qtyNo = qty
time.sleep(0.5)
continue
continue
continue
continue
time.sleep(2)
job_id = 0
built = built + 1
build1 = 0
kj = 0
if checkup > 1:
time.sleep(3)
time.sleep(1)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&units%5Bquantity%5D={2}×tamp={3}&%5Fsession%5Fid={4}&units%5Bunit%5Ftype%5D=Minotaur&%5Fmethod=delete&version=overarch'.format(user_id, dragon_heart, datam, int(time.time()), session_id)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/release.json'.format(realm_number, c, capital_id)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
print('\nReleasing remaining mino')
time.sleep(1)
realm = 'realm%d.c%d.castle.rykaiju.com' % (realm_number, c)
params = 'user%5Fid={0}&dragon%5Fheart={1}&units%5Bquantity%5D={2}×tamp={3}&%5Fsession%5Fid={4}&units%5Bunit%5Ftype%5D={5}&%5Fmethod=delete&version=overarch'.format(user_id, dragon_heart, datatr, int(time.time()), session_id, Ttype)
url = 'http://realm{0}.c{1}.castle.rykaiju.com/api/cities/{2}/units/release.json'.format(realm_number, c, capital_id)
cadena = 'Draoumculiasis' + params + 'LandCrocodile' + url + 'Bevar-Asp'
cadenau = cadena.encode('utf8')
m = hashlib.sha1(cadenau)
xs3 = m.hexdigest()
headers = {
'Host': realm,
'Connection': 'keep-alive',
'Content-Length': len(params),
'Origin': 'http://castlemania-production.s3.amazonaws.com',
'x-s3-aws': xs3,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11',
'content-type': 'application/x-www-form-urlencoded',
'Accept': '*/*',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'es-ES,es;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'DNT': 1,
'Cookie': cookie }
conn = http.client.HTTPConnection(realm, 80)
conn.request('POST', url, params, headers)
print('\nReleasing remaining: ', name)
print('\nNumber of BATCHES done: ', built)
print('***********************\nItems used:')
print('===========')
if testro != 0:
print('Dark Testronius Powder: ', testro * built)
if deluxe != 0:
print('Dark Testronius Deluxe: ', deluxe * built)
if infu != 0:
print('Dark Testronius Infusion: ', infu * built)
if jump != 0:
print('Jump: ', jump * built)
if leap != 0:
print('Leap: ', leap * built)
if bounce != 0:
print('Bounce: ', bounce * built)
if bore != 0:
print('Bore: ', bore * built)
if bolt != 0:
print('Bolt: ', boltbr)
if blast != 0:
print('Blast: ', blast * built)
if blitz != 0:
print('Blitz: ', blitz * built)
if build > 1 and build != built:
print('\nWaiting for generals...')
time.sleep(10)
time.sleep(Duration)
totalpower = number * built * power
elapsed_time = time.time() - start_time
print(79 * '=')
print('\nElapsed time: {0}'.format(time.strftime('%H:%M:%S', time.gmtime(elapsed_time))))
print('\n\nRevived {0} of {1} in total power of {2}'.format(format(number * built, ',d'), name, format(totalpower, ',d')))
print('\nReviving completed!!\n')
print(79 * '=')
input('Press Enter to Exit...')