gopiashokan commited on
Commit
f52713c
1 Parent(s): e7d876e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -13,6 +13,7 @@ from langchain.chains.question_answering import load_qa_chain
13
  from selenium import webdriver
14
  from selenium.webdriver.common.by import By
15
  from selenium.webdriver.common.keys import Keys
 
16
  import warnings
17
  warnings.filterwarnings('ignore')
18
 
@@ -366,21 +367,17 @@ class linkedin_scraper:
366
  def open_link(driver, link):
367
 
368
  while True:
369
-
370
- # Open the Link
371
- driver.get(link)
372
- driver.implicitly_wait(10)
373
- time.sleep(3)
374
-
375
- # Check the Page Loaded Correctly and Break the Loop
376
- if driver.find_element(by=By.CSS_SELECTOR, value='span[class="switcher-tabs__placeholder-text m-auto"]'):
377
- break
378
-
379
- # Page not Loaded Properly, Again Open the Page
380
- else:
381
  driver.get(link)
382
- driver.implicitly_wait(10)
383
  time.sleep(3)
 
 
 
 
 
 
384
 
385
 
386
  def link_open_scrolldown(driver, link, job_count):
 
13
  from selenium import webdriver
14
  from selenium.webdriver.common.by import By
15
  from selenium.webdriver.common.keys import Keys
16
+ from selenium.common.exceptions import NoSuchElementException
17
  import warnings
18
  warnings.filterwarnings('ignore')
19
 
 
367
  def open_link(driver, link):
368
 
369
  while True:
370
+ # Break the Loop if the Element is Found, Indicating the Page Loaded Correctly
371
+ try:
 
 
 
 
 
 
 
 
 
 
372
  driver.get(link)
373
+ driver.implicitly_wait(5)
374
  time.sleep(3)
375
+ driver.find_element(by=By.CSS_SELECTOR, value='span.switcher-tabs__placeholder-text.m-auto')
376
+ return
377
+
378
+ # Retry Loading the Page
379
+ except NoSuchElementException:
380
+ continue
381
 
382
 
383
  def link_open_scrolldown(driver, link, job_count):