email scraper_help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: email scraper_help (/thread-949.html) |
email scraper_help - Blue Dog - Nov-16-2016 This is a video I watched on you tube. It work ok from him, not for me. In this code I have comments telling you what I know about this code. I am using selenium, I have never used this mod. be for. here it is: # I know what this does, I just don't know if it is right from selenium import webdriver #I know this is right import re #this is where the problem is,webdriver.chrome() is the problem. driver = webdriver.chrome() #This open thr url driver,get("http://www.networksecuritybybluedog.com/") #This is a var that make the page sourse the same as doc doc = driver.page_sourse #Now I know that emails = re.findall is looking for everything that #match this r'[\w\.-]+@[\w\.-]+' I am not sure how this works. To me #it looks like r+read all that match this [\w\.-]+@[\w\.-]. It looks # to me that this is sayin write every thing from the space befor # @ write to the next space everything after@ emails = re.findall(r'[\w\.-]+@[\w\.-]+', doc) #this is a for loop email keep looping untill there no more emails for email in emails: # this is print the var email print(email) I have a felling this is 3.5 pythonI hope some one can help me understand this code better Thank you RE: email scraper_help - metulburr - Nov-16-2016 i believe its Chrome() and http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium RE: email scraper_help - Blue Dog - Nov-16-2016 never mind, it looks like I have to install chrome. We will see how hard this is going be. thank you RE: email scraper_help - snippsat - Nov-16-2016 Have to capitalize chrome() and set path. driver = webdriver.Chrome(executable_path="C:/path_to/chromedriver.exe") RE: email scraper_help - Blue Dog - Nov-16-2016 Thank you snippsat RE: email scraper_help - Gaurav_Kumar - Aug-11-2023 It seems like you're trying to use Selenium to scrape emails from a website, but you're encountering an error related to the webdriver initialization. The error message indicates that you're trying to call a module as if it were a function, which is causing the TypeError. The correct way to initialize a webdriver for Chrome in Selenium is to use webdriver.Chrome() (with a capital "C" in Chrome). Here's a corrected version of your code with explanations: # Import the required module correctly from selenium import webdriver import re # Initialize the Chrome webdriver instance driver = webdriver.Chrome() # Use 'Chrome' instead of 'chrome' # Open the URL driver.get("http://www.networksecuritybybluedog.com/") # Get the page source doc = driver.page_source # Find all email addresses using regular expression emails = re.findall(r'[\w\.-]+@[\w\.-]+', doc) # Loop through the emails and print them for email in emails: print(email) # Close the browser window when done driver.quit()Make sure you have the Selenium library and the appropriate web driver executable (in this case, ChromeDriver) installed and properly configured. You should also remember to close the browser window using driver.quit() after you're done to free up system resources. Additionally, ensure that you have the Chrome web driver executable installed and added to your system's PATH. You can download ChromeDriver from the official site: https://sites.google.com/chromium.org/driver/ RE: email scraper_help - snippsat - Aug-11-2023 @Gaurav_Kumar look at date of Thread and the answer given,before answer. This Thread was solved in 2016. |