Novice programmer, currently making a WebCrawler
and came up with
driver.close()
^incorrect syntax as shown below,
However, I used driver above with no problem so I'm pretty perplexed at the moment
I appreciate all the help I can get
thanks in advance team
import sys
from selenium import webdriver as wd
# from bs4 import BeautifulSoup as bs
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# import pymysql as my
import time
# from Tour import TourInfo
# First Url =
# https://stamprally.org/?search_keywords=&search_keywords_operator=and&search_cat1=145&search_cat2=0
# Second Url =
# https://stamprally.org/?search_keywords=&search_keywords_operator=and&search_cat1=66&search_cat2=0
driver.get(main_url)
try:
element = WebDriverWait(driver, 10).until(
# 지정한 요소 한개가 발견되면 웨이트 종료
EC.presence_of_element_located((By.ID, 'header_search_cat1'))
)
except Exception as e:
print('오류 발생', e)
driver.implicitly_wait(10)
for prefectureValue in range(66, 121):
offshorePrefectureValue = 145
try:
driver.get(
f"https://stamprally.org/?search_keywords=&search_keywords_operator=and&search_cat1={prefectureValue}&search_cat2=0)")
print(driver.current_url)
# close off
driver.close()
driver.quit()
sys.exit()
SyntaxError: invalid syntax
PS C:\Users\eong\Desktop\stamprally_crawl> python run.py
File "C:\Users\eong\Desktop\stamprally_crawl\run.py", line 70
driver.close()
^
SyntaxError: invalid syntax