Deploy Scrapper facebook post on Heroku using Selenium Python

Viewed 170

Here is my config to using chrome driver on Heroku

chrome_options = webdriver.ChromeOptions()           
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
chrome_options.add_argument("--headless")           
chrome_options.add_argument("--disable-dev-shm-usage")           
chrome_options.add_argument("--no-sandbox")           
chrome_options.add_argument("--start-maximized")           
chrome_options.add_argument('--disable-gpu')
           
chrome =webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"),chrome_options=chrome_options)
chrome.get("https://facebook.com/groups/744721719556973/")

My duty is crawling post from a public group.So I selenium and beautifulsoup It worked very well on Local ,I cralwed data successfully.But when I deploy it to heroku it return an empty array

My config in local

  options = Options() 
  options.add_argument("--disable-notifications") 
  options.add_argument("--headless") \# options.add_argument("--start-maximized") 
  options.add_argument("--disable-dev-shm-usage") \# options.add_argument("--start-maximized") 
  options.add_argument("--no-sandbox")
# chrome = webdriver.Chrome('./chromedriver', chrome_options=options)
# chrome.get("https://facebook.com/groups/744721719556973/")`
//scroll to crawl post
chrome.execute_script("window.scrollTo(0,document.body.scrollHeight)")  
tree = html.fromstring(chrome.page_source)  
soup = BeautifulSoup(chrome.page_source, 'html.parser')  

Here is my way

//this still work on local but on heroku it doenst find any div with the these classes
match = soup.find_all('div', class\_='du4w35lb k4urcfbm l9j0dhe7 sjgh65i0')
 options.add_argument("--disable-notifications")     
 options.add_argument("--headless")     
 options.add_argument("--start-maximized")     
 options.add_argument("--disable-dev-shm-usage")     
 options.add_argument("--start-maximized")    
 options.add_argument("--no-sandbox")

I tried many way but it doesnt work.If you overcame this problem,suggest me pls.Tks u you so much

1 Answers
Related