Skip to content

Commit

Permalink
add github actions for automating
Browse files Browse the repository at this point in the history
  • Loading branch information
phitrann committed Mar 8, 2024
1 parent 83a80c2 commit 2f522c9
Show file tree
Hide file tree
Showing 4 changed files with 879 additions and 804 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
schedue:
- cron: '0 4 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
17 changes: 9 additions & 8 deletions crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@

wait = WebDriverWait(browser, 10)

# Tắt quảng cáo
wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="onesignal-slidedown-cancel-button"]'))).click()

close_buttons = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'button.MuiIconButton-root[aria-label="close"]')))
for close_button in close_buttons[1:]:
close_button.click()

# Chọn sử dụng cookie
wait.until(EC.element_to_be_clickable((By.XPATH, '//div[@role="dialog"]//button'))).click()

# # Tắt quảng cáo
# wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="onesignal-slidedown-cancel-button"]'))).click()

# close_buttons = wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'button.MuiIconButton-root[aria-label="close"]')))
# for close_button in close_buttons[1:]:
# close_button.click()


# Chọn vé một chiều
wait.until(EC.element_to_be_clickable((
By.XPATH, '//span[contains(text(),"Một chiều")]'))).click()
Expand Down Expand Up @@ -70,7 +71,7 @@
str_time = 'tháng '+ tomorrow_month + ' ' + tomorrow_year

wait.until(EC.presence_of_element_located((
By.XPATH, '//*[contains(text(),"{a}")]//following-sibling::div[2]//descendant::span[contains(text(),"{b}")]'.format(a = str_time, b = tomorrow_day)))).click()
By.XPATH, '//*[contains(text(),"{a}")]//following-sibling::div[2]//descendant::span[text()="{b}"]'.format(a = str_time, b = tomorrow_day)))).click()

# Click Tìm chuyến bay
submit = wait.until(EC.visibility_of_element_located((By.XPATH, '(//*[contains(text(), "Tìm chuyến bay")])[2]')))
Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
selenium
webdriver-manager
beautifulsoup4
lxml
Loading

0 comments on commit 2f522c9

Please sign in to comment.