The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Sending multiple HTTP request at once? help
Discuss Sending multiple HTTP request at once? help in the Python Programming forum on Dev Shed. Sending multiple HTTP request at once? help Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 8th, 2013, 02:08 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
|
|
|
Sending multiple HTTP request at once? help
Ok so I have a program that sends HTTP requests however it does one http request and then the next one after that?
However I want it to all search at the same time(doesnt need to be exactly the same time) but i dont want them to que i want them all the go off all at once?
ive tried multithreading but that doesnt seem to work?
I have been trying this:
Code:
threading.Thread(target = doSomething).start()
Any help would be greatly appreciated!
Thanks in advance!

|

January 9th, 2013, 01:45 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
|
|
Nobody know?  is this possible?
|

January 9th, 2013, 02:35 PM
|
 |
Contributing User
|
|
|
|
|
Perhaps doSomething contains a statement that blocks until doSomething finishes?
__________________
[code] Code tags[/code] are essential for python code!
|

January 9th, 2013, 06:07 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
|
|
The code include this:
Code:
def Vermaelen(): client = FifaClient(EMAIL, PASSWORD, HASH, AUTHDATA) while client.getCoins() > 500 and len(client.getTradePileId()[0]) < 30: searchURL = 'https://utas.fut.ea.com/ut/game/fifa13/auctionhouse?type=player&start=0&team=1&lev=gold&num=16&nat=7&pos=CB&maxb=2000' req = urllib2.Request(searchURL) req.add_header('Cookie', client.EASW_KEY + '; ' + client.EASF_SESS + '; ' + client.FUTPHISHING + '; ') req.add_header('Content-Type', 'application/json') req.add_header('x-http-method-override', 'GET') req.add_header('X-UT-SID', client.XUT_SID) d = urllib2.urlopen(req) searchXML = dict(json.loads(d.read())) auctionInfo = searchXML.get('auctionInfo') for contract in auctionInfo: tradeID = contract.get('tradeId') buyPrice = contract.get('buyNowPrice') rating = contract.get('itemData').get('rating') discVal = contract.get('itemData').get('discardValue') itemID = contract.get('itemData').get('id') if rating == 82: client.buyItem(tradeID, buyPrice) print('Bought Vermaelen(' +str(discVal) + ')(' + str(rating) + ')for ' + str(buyPrice) + ' coins! Coins left: ' + str(client.getCoins())) if client.moveCard(str(itemID), 'trade'): client.postTrade(str(itemID), str(3800), str(3900), str(3600)) tradePileCards = client.getTradePileId() for x in range(0, client.getTradePileLegnth()): client.postTrade(str((tradePileCards[0])[x]), str((tradePileCards[2])[x]), str(0), str(3600)) def doVermaelen(): while 1: try: client = FifaClient(EMAIL, PASSWORD, HASH, AUTHDATA) Vermaelen() time.sleep(3) except Exception, e: time.sleep(60)
|

January 9th, 2013, 08:17 PM
|
 |
Contributing User
|
|
|
|
|
Please review your post, recognize it is next to useless, and fix it.
|

January 10th, 2013, 12:52 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
|
|
sorry..here you go:
Code:
def Piszczek():
client = FifaClient(EMAIL, PASSWORD, HASH, AUTHDATA)
while client.getCoins() > 500 and len(client.getTradePileId()[0]) < 30:
searchURL = 'https://utas.fut.ea.com/ut/game/fifa13/auctionhouse?type=player&start=0&team=22&lev=gold&num=16&nat=37&pos=RB&maxb=6000'
req = urllib2.Request(searchURL)
req.add_header('Cookie', client.EASW_KEY + '; ' + client.EASF_SESS + '; ' + client.FUTPHISHING + '; ')
req.add_header('Content-Type', 'application/json')
req.add_header('x-http-method-override', 'GET')
req.add_header('X-UT-SID', client.XUT_SID)
d = urllib2.urlopen(req)
searchXML = dict(json.loads(d.read()))
auctionInfo = searchXML.get('auctionInfo')
for contract in auctionInfo:
tradeID = contract.get('tradeId')
buyPrice = contract.get('buyNowPrice')
rating = contract.get('itemData').get('rating')
discVal = contract.get('itemData').get('discardValue')
itemID = contract.get('itemData').get('id')
if rating == 82:
client.buyItem(tradeID, buyPrice)
print('Bought Piszczek(' +str(discVal) + ')(' + str(rating) + ')for ' + str(buyPrice) + ' coins! Coins left: ' + str(client.getCoins()))
if client.moveCard(str(itemID), 'trade'):
client.postTrade(str(itemID), str(1900), str(2000), str(3600))
tradePileCards = client.getTradePileId()
for x in range(0, client.getTradePileLegnth()):
client.postTrade(str((tradePileCards[0])[x]), str((tradePileCards[2])[x]), str(0), str(3600))
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|