This repository was archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbid.py
More file actions
39 lines (35 loc) · 1.6 KB
/
bid.py
File metadata and controls
39 lines (35 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from login import login
import requests
from lxml.html import fromstring
import time
def bid_specific_auction(server, auction_id_or_link, price, delay=True):
"""Bidding an auction few seconds before it's end"""
URL = f"https://{server}.e-sim.org/"
if ".e-sim.org/auction.html?id=" in auction_id_or_link:
auction_id_or_link = auction_id_or_link.split("=")[1]
auction_url = requests.get(f"{URL}auction.html?id={auction_id_or_link}", verify=False)
tree = fromstring(auction_url.content)
try:
auction_time = str(tree.xpath(f'//*[@id="auctionClock{auction_id}"]')[0].text)
except:
print("This auction has probably finished. if you think this is mistake -"
" you are welcome to run the function again, but this time write the delay yourself")
return
h, m, s = auction_time.split(":")
if delay:
delay_in_seconds = int(h) * 3600 + int(m) * 60 + int(s) - 30
time.sleep(delay_in_seconds)
session = login(server)
payload = {'action': "BID", 'id': auction_id_or_link, 'price': price}
post_bid = session.post(URL + "auctionAction.html", data=payload)
print(post_bid.url)
return session
if __name__ == "__main__":
print(bid_specific_auction.__doc__)
server = input("Server: ")
auction_id = input("Auction id: ")
price = input("Your bid: ")
delay = input("Bid near auctions end? (y/n): ")
delay = True if delay.lower() == "y" else False
bid_specific_auction(server, auction_id, price, delay=False if delay == "n" else True)
input("Press any key to continue")