It's selenium. and the development environment pycharm
What does the yellow line in import os mean? and Hod do I solve This error??
And I want to save images crawled by Google using Selenium to my desktop file.
desktop file name 'Image'.
file address is '/Users/jun/Desktop/PyCham/selenium image folder
help me . I'm english pool sorry.
CodePudding user response:
You have to mention from where to import the os.
Similarly to
from selenium import webdriver
You have to mention from where os
will be imported.
BTW, also, path
need to contain the hromedriver
with the extension.
Like this:
path = 'C:\webdrivers\chromedriver.exe'
CodePudding user response:
import os
is highlighted because before it you have an infinite loop. This code
while True:
browser.find_element_by_tag_name('body').send_keys(Keys.PAGE_DOWN)
time.sleep(1)
will never end because there are no conditions to stop this while loop and no breaks implemented.
So all the code under this while
is unreachable, including the import os
Also I see that the path to the folder is too long and it looks like you pasted it two times. As far as you use MacOS (according to the file system structure), the path should start with /Users/