I am Japanese and basically write articles in Japanese, but this time I decided to write in English.
This is a page that summarizes what has been done until the completion of the automatic purchase bot.
I would like to upload other articles in English as well. It takes time.
Basically, you can see it by looking at the link.
If you have any questions, please leave a comment.
目次
A series of flows
Problems found when creating
Simple operation explanation
- Enter the URL of the ticket you want to get
- Enter the start time
- Detects and corrects discrepancies between PC and Internet time signals
- Log in to the site 2 minutes ago
- Purchase at the set start time
Roughly like this
Code
I will publish a part of the completed code for the time being.
I want to post what I made, and not everyone can do it with this code.
I hope it will serve as a reference only.
Most of them can be copied, but the code will change depending on whether it is Amazon, Rakuten, or the site for automatic purchase.
This time I used it to buy a ticket for a Japanese underground idol.
I was also able to take the reference number 1
Some things that change depending on the site, such as clicking a button or entering characters, are broken.
(Because it will change depending on the site even if it is posted)
The specific part to change is the contents of def ().
Please refer to it for other articles such as basic operation.
PythonとSeleniumでスクレイピング Seleniumを用いた自動購入Bot(試作)If you want to make it, please do your best.
I was able to make it properly even with inexperienced self-study
import requests
from bs4 import BeautifulSoup
import math
import time
from time import sleep
import datetime
import schedule
from datetime import timedelta
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument('--disable-desktop-notifications')
options.add_argument("--disable-extensions")
options.add_argument('--lang=ja')
options.add_argument('--blink-settings=imagesEnabled=false')
options.add_argument("--proxy-server='direct://'")
options.add_argument("--proxy-bypass-list=*")
driver = webdriver.Chrome(chrome_options=options)
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
driver.set_window_size(1045,722) # window size change
url1 = "https://t"
url2 = input("ticket-URL>")
login = "gmail.com"
password = "k"
start = input("開始時間>")
start1 = datetime.datetime.strptime(start, '%H:%M:%S').time()
start2 = datetime.datetime.combine(datetime.date.today(), start1) - datetime.timedelta(minutes=2)
start3 = start2.strftime("%H:%M:%S")
r = requests.get('https://ntp-a1.nict.go.jp/cgi-bin/jst')
soup = BeautifulSoup(r.text,'lxml')
t1 = soup.find("body").string
t2 = t1.rstrip('\n')
t3 = time.time()
t4 = float(t2)-t3
if t4 >= 0:
t5 = 0
t6 = math.ceil(t4)
t7 = t4 - t6
else:
t5 = -t4
t6 = 0
t7 = 0
start5 = datetime.datetime.combine(datetime.date.today(), start1) + datetime.timedelta(seconds = t6)
start6 = start5.strftime("%H:%M:%S")
def Login():
driver.get(url1)
print(datetime.datetime.now())
print("ログイン出来ました。")
def Main():
sleep(t5)
sleep(t7)
driver.get(url2)
driver.find_element_by_name('c').submit()
print(datetime.datetime.now())
print("get")
sleep(5)
driver.quit()
schedule.every().day.at(start3).do(Login)
schedule.every().day.at(start6).do(Main)
while True:
schedule.run_pending()
time.sleep(0.1)
finally
I made it while checking various things.
Even a beginner in programming could make it. It depends on your efforts.
As a result, my knowledge of Python was also good.
This completes the creation of the automatic purchase bot.
I may write articles that are still relevant, but lol
After all, the speed of purchase depends on the internet connection.
If you want to get a good number with a ticket etc., use a faster line.
Notice: Android app
I thought about purchasing tickets etc. with the Android application.
Let me press the refresh button on your browser.
Android限定:時間指定してタップしてくれるアプリ
Thanks , I’ve recently been looking for information approximately this
topic for a while and yours is the best I’ve found out so far.
However, what about the bottom line? Are you positive about the source?
Thank you for your comment.
Revenue is still quite low.
If you can understand it!
Would you like to translate other articles into English?
However, although it is not good English