I am trying to scrape the name of college and addresses from a site : https://www.collegenp.com/2-science-colleges/ , but the problem is that i am only getting the data of first 11 college present in the list and not getting data of others. I had tried everything i know.But none method work.
My code is :
from selenium import webdriver
import bs4
from bs4 import BeautifulSoup
import requests
import pandas as pd
from time import sleep
driver=webdriver.Chrome('C:/Users/acer/Downloads/chromedriver.exe')
driver.get('https://www.collegenp.com/2-science-colleges/')
driver.refresh()
sleep(20)
page=requests.get("https://www.collegenp.com/2-science-colleges/")
college = []
location=[]
soup= BeautifulSoup(page.content,'html.parser')
for a in soup.find_all('div',attrs={'class':'media'}):
name=a.find('h3',attrs={'class':'college-name'})
college.append(name.text)
loc=a.find('span',attrs={'class':'college-address'})
location.append(loc.text)
df=pd.DataFrame({'College name':college,'Locations':location})
df.to_csv('hell.csv',index=False,encoding='utf-8')
Is there any way so that i can scrape all the data?