Python Forum
Combining selenium and beautifulsoup for web scraping
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combining selenium and beautifulsoup for web scraping
#2
(Jan-29-2018, 07:05 AM)sumandas89 Wrote: can I enter into webpages using selenium and then scrape data from there using beautifulsoup?
Yes if you need to get past javascript, you can use selenium to get the full page content and pass it to BS.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(WEBSITE)
#delay of some kind wait for load time.sleep(3) or selenium wait for an element to be visible
soup = BeautifulSoup(driver.page_source, 'html')
However selenium has methods to get navigate HTML, as you will need it to get past multiple javascript pages/mouse clicks. So it depends really on whether you need BS after already using selenium.

(Jan-29-2018, 07:05 AM)sumandas89 Wrote: I observed that beautifulsoup never work on those pages needs login, so I need to login first to that website using selenium
You can login to website with requests module and saving cookies, etc. Selenium is not required to login to a website unless it has javascript.
Recommended Tutorials:
Reply


Messages In This Thread
RE: Combining selenium and beautifulsoup for web scraping - by metulburr - Jan-29-2018, 07:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scraping div tags with selenium, need help hfakoor2 1 1,133 Mar-12-2023, 08:31 AM
Last Post: hfakoor2
  Scraping based on years BeautifulSoup rhat398 0 1,792 May-22-2021, 07:20 PM
Last Post: rhat398
  Web scraping cookie in URL blocks selenium Alex06 2 2,485 Jan-10-2021, 01:43 PM
Last Post: Alex06
  Extract data with Selenium and BeautifulSoup nestor 3 4,002 Jun-06-2020, 01:34 AM
Last Post: Larz60+
  Beautifulsoup Scraping PolskaYBZ 3 3,239 Jun-22-2019, 10:05 AM
Last Post: PolskaYBZ
  Web scraping (selenium (i think)) Larz60+ 10 6,319 Jan-27-2019, 02:57 AM
Last Post: Larz60+
  Web Page not opening while web scraping through python selenium sumandas89 4 10,177 Nov-19-2018, 02:47 PM
Last Post: snippsat
  web scraping with selenium and bs4 Prince_Bhatia 2 3,816 Sep-18-2018, 10:59 AM
Last Post: Prince_Bhatia
  scraping javascript websites with selenium DoctorEvil 1 3,420 Jun-08-2018, 06:40 PM
Last Post: DoctorEvil
  web scraping using selenium sumandas89 3 3,628 Jan-05-2018, 01:45 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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