#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep 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!

  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0
    Nobody know? is this possible?
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Perhaps doSomething contains a statement that blocks until doSomething finishes?
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep 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)
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Please review your post, recognize it is next to useless, and fix it.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep 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))

IMN logo majestic logo threadwatch logo seochat tools logo