Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
email scraper_help
#6
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/
Reply


Messages In This Thread
email scraper_help - by Blue Dog - Nov-16-2016, 12:48 AM
RE: email scraper_help - by metulburr - Nov-16-2016, 12:53 AM
RE: email scraper_help - by Blue Dog - Nov-16-2016, 12:54 AM
RE: email scraper_help - by snippsat - Nov-16-2016, 01:36 AM
RE: email scraper_help - by Blue Dog - Nov-16-2016, 02:29 PM
RE: email scraper_help - by Gaurav_Kumar - Aug-11-2023, 12:24 PM
RE: email scraper_help - by snippsat - Aug-11-2023, 01:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Django send email - email form Remek953 2 2,317 Sep-18-2020, 07:07 AM
Last Post: Remek953

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020