For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2007 > Need a Help to conver the small Python program to Perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need a Help to conver the small Python program to Perl
wnjayantha@yahoo.com

2007-01-23, 7:04 pm

import urllib
import urllib2
from xml.dom import minidom

user="YourUserName"
password="YourPassword"

site='https://test.api.betfairgames.com/rest/v1/bet/order'
site=site+"?username="+user

xml_request1="""<postBetOrder
xmlns="https://api.betfairgames.com/rest/v1"
round="1" marketId="3829306" currency="GBP">
<betPlace>
<bidType>BACK</bidType>
<price>2.6</price>
<size>4</size>
<selectionId>658439</selectionId>
</betPlace>
</postBetOrder>"""

values = {'xmlRequest':xml_request}
data=urllib.urlencode(values)

req=urllib2.Request(site)
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
req. add_header('gamexAPIAgent','maryBrown@AO
L.com.myGames.4.0')
req. add_header('gamexAPIAgentInstance','0d69
ee8290ee2f9b336c1f060e3497a5')
req.add_header('gamexAPIPassword',password)
req.add_header('Keep-Alive','300')
req.add_header('Proxy-Connection','keep-alive')
req.add_header('Content-Type','application/x-www-form-urlencoded')
req.add_header('Content-Length',str(len(data)))
req.add_data(data)

xmlresult = urllib2.urlopen(req)
xmlparser = minidom.parse(xmlresult)

print xmlparser.toxml()

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com