joeyism / linkedin_scraper

A library that scrapes Linkedin for user data
GNU General Public License v3.0
2.01k stars 560 forks source link

TimeoutException: Message: #70

Open reddyakilesh22 opened 3 years ago

reddyakilesh22 commented 3 years ago
import os   
from selenium import webdriver
import time    
from linkedin_scraper import actions    
from selenium import webdriver    
from selenium.webdriver.common.by import By    
from selenium.webdriver.support.ui import WebDriverWait    
from selenium.webdriver.support import expected_conditions as EC    
from selenium.common.exceptions import TimeoutException    
from selenium.webdriver.chrome.options import Options

chrome_options = Options()    
chrome_options.add_argument("--headless")

driver = webdriver.Chrome("driver/chromedriver", options=chrome_options)    
email = os.getenv("LINKEDIN_USER")    
password = os.getenv("LINKEDIN_PASSWORD")

actions.login(driver, email, password) # if email and password isnt given, it'll prompt in terminal
driver.get('https://www.linkedin.com/company/biorasi-llc/about/')

_ = WebDriverWait(driver, 3).until(EC.presence_of_all_elements_located((By.TAG_NAME, 'section')))

time.sleep(3)    
grid = driver.find_elements_by_tag_name("section")[3]
about_us = grid.find_elements_by_tag_name("p")[0].text.strip()

print(about_us)

This is the code I used and I'm getting an error like:

TimeoutException                          Traceback (most recent call last)
<ipython-input-9-d0ec172cd3eb> in <module>
     18 password = os.getenv("LINKEDIN_PASSWORD")
     19 
---> 20 actions.login(driver, email, password) # if email and password isnt given, it'll prompt in terminal
     21 driver.get('https://www.linkedin.com/company/biorasi-llc/about/')
     22 

~\Anaconda3\lib\site-packages\linkedin_scraper\actions.py in login(driver, email, password)
     28   password_elem.submit()
     29 
---> 30   element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "profile-nav-item")))

~\Anaconda3\lib\site-packages\selenium\webdriver\support\wait.py in until(self, method, message)
     78             if time.time() > end_time:
     79                 break
---> 80         raise TimeoutException(message, screen, stacktrace)
     81 
     82     def until_not(self, method, message=''):

TimeoutException: Message: 
sargupta commented 3 years ago

@joeyism I am having same issue (attached) Screenshot 2020-12-09 at 00 05 12

reddyakilesh22 commented 3 years ago

Yup, I'm getting the same thing as @sargupta. @joeyism Please look into this.

joeyism commented 3 years ago

It seems like this has to do with linkedin not letting you login. If you don't use --headless, what does Linkedin on Chrome look like?

akshayminocha5 commented 3 years ago

Having the same issue

reddyakilesh22 commented 3 years ago

@akshayminocha5 Bro add/do these changes and it will work.

from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

dazulu4 commented 3 years ago

I have the same problem but the solution proposed don't work for me. This is my code:

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/chromium-browser'
driver_binary = "/usr/bin/chromedriver"

#driver = webdriver.Chrome(driver_binary, chrome_options=options)
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

email = "username@gmail.com"
password = "password"
actions.login(driver, email, password)

I get the following error:

/usr/local/lib/python3.7/dist-packages/webdriver_manager/utils.py in chrome_version(browser_type)
    140     version = re.search(pattern, stdout)
    141     if not version:
--> 142         raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
    143     current_version = version.group(0)
    144     return current_version

ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version

And this is my chrome and chromedriver versions:

Please help!

joeyism commented 3 years ago

I have the same problem but the solution proposed don't work for me. This is my code:

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/chromium-browser'
driver_binary = "/usr/bin/chromedriver"

#driver = webdriver.Chrome(driver_binary, chrome_options=options)
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

email = "username@gmail.com"
password = "password"
actions.login(driver, email, password)

I get the following error:

/usr/local/lib/python3.7/dist-packages/webdriver_manager/utils.py in chrome_version(browser_type)
    140     version = re.search(pattern, stdout)
    141     if not version:
--> 142         raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
    143     current_version = version.group(0)
    144     return current_version

ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version

And this is my chrome and chromedriver versions:

  • Chromium 87.0.4280.66 Built on Ubuntu
  • ChromeDriver 87.0.4280.66

Please help!

Do you have google-chrome or google-chrome-stable installed?

dazulu4 commented 3 years ago

I have the same problem but the solution proposed don't work for me. This is my code:

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/chromium-browser'
driver_binary = "/usr/bin/chromedriver"

#driver = webdriver.Chrome(driver_binary, chrome_options=options)
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

email = "username@gmail.com"
password = "password"
actions.login(driver, email, password)

I get the following error:

/usr/local/lib/python3.7/dist-packages/webdriver_manager/utils.py in chrome_version(browser_type)
    140     version = re.search(pattern, stdout)
    141     if not version:
--> 142         raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
    143     current_version = version.group(0)
    144     return current_version

ValueError: Could not get version for Chrome with this command: google-chrome --version || google-chrome-stable --version

And this is my chrome and chromedriver versions:

  • Chromium 87.0.4280.66 Built on Ubuntu
  • ChromeDriver 87.0.4280.66

Please help!

Do you have google-chrome or google-chrome-stable installed?

No, I only installed Chromium browser!

joeyism commented 3 years ago

@dazulu4 you need to install google-chrome or google-chrome-stable

aradzekler commented 3 years ago

I'm getting exactly the same error: File "C:\Users\User\PycharmProjects\dough\scraping\linkedin_profile_scraper\actions.py", line 48, in login WebDriverWait(driver, randint(5, 6)).until(EC.presence_of_element_located((By.ID, "profile-nav-item"))) File "C:\Users\User\anaconda3\envs\scraping_env_3_8\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: when trying to log in to LinkedIn, havent change anything in actions.py and it started happening today (everything worked till now), maybe LinkedIn changed something? maybe something with "profile-nav-item". the problem happens also with a wait time=300.

joeyism commented 3 years ago

Try 2.8.2