Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 8th, 2013, 02:08 PM
codingbenn codingbenn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 4 codingbenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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!


Reply With Quote
  #2  
Old January 9th, 2013, 01:45 PM
codingbenn codingbenn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 4 codingbenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 sec
Reputation Power: 0
Nobody know? is this possible?

Reply With Quote
  #3  
Old January 9th, 2013, 02:35 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,372 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 11 h 41 m 46 sec
Reputation Power: 383
Perhaps doSomething contains a statement that blocks until doSomething finishes?
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #4  
Old January 9th, 2013, 06:07 PM
codingbenn codingbenn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 4 codingbenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

Reply With Quote
  #5  
Old January 9th, 2013, 08:17 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,372 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 11 h 41 m 46 sec
Reputation Power: 383
Please review your post, recognize it is next to useless, and fix it.

Reply With Quote
  #6  
Old January 10th, 2013, 12:52 PM
codingbenn codingbenn is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 4 codingbenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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))
            

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Sending multiple HTTP request at once? help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap