KOSEN{BLOG}について

Until the automatic purchase bot is completed

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

手順2
Scraping with Selenium
手順3
Easy to create while looking at the internet
手順4
Improvement of problems
Shown below

Problems found when creating

問題1
Time calculation (to perform login processing n minutes before)
問題2
Element not found (resulting in a time issue)
問題3
Time difference in PC (detects time difference from Internet time signal)
問題4
Judge and correct the deviation with the if statement

Simple operation explanation

  1. Enter the URL of the ticket you want to get
  2. Enter the start time
  3. Detects and corrects discrepancies between PC and Internet time signals
  4. Log in to the site 2 minutes ago
  5. 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.

 

2 COMMENTS

News Proxy

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

返信する

コメントを残す

メールアドレスが公開されることはありません。