Есть ли способ заставить его работать, даже когда я Я просматриваю другую вкладку/окно?
(Интересно, как веб-сайт узнает, что я на самом деле просматриваю веб-страницу или нет...)
#This is a job website in Japanese
login_url = "https://mypage.levtech.jp/"
driver = selenium.webdriver.Chrome("./chromedriver")
#Account and password are required to log in.
#I logged in and got to the following page, which displays a list of companies that I have applied for:
#https://mypage.levtech.jp/recruits/screening
#Dictionary to store company names and their job postings
jobs = {}
for i, company in enumerate(company_names):
time.sleep(1)
element = driver.find_elements_by_class_name("ScreeningRecruits_ListItem")
while element.text == "":
#While loops and time.sleep() are there because the webpage seems to take a while to load
time.sleep(0.1)
element = driver.find_elements_by_class_name("ScreeningRecruits_ListItem")
td = element.find_element_by_tag_name("td")
while td.text == "":
time.sleep(0.1)
td = element.find_element_by_tag_name("td")
if td.text == company:
td.click()
time.sleep(1)
jobs[company] = get_job_desc(driver) #The get_job_desc function checks HTML tags and extract info from certain elements
time.sleep(1)
driver.back()
time.sleep(1)
print(jobs)
Кстати, я попробовал добавить пользовательский агент и прокрутить страницу вниз, используя следующий код, в надежде, что веб-страница поверит, что я «смотрю на нее». " Ну, у меня не получилось
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
Подробнее здесь: https://stackoverflow.com/questions/648 ... ti-crawler
Мобильная версия