RogueFairyStudios / CineMonster

Telegram Bot Quiz About Series and Movies
Apache License 2.0
16 stars 23 forks source link

Using web scrapping to get movie names #10

Closed meetanubhav closed 6 years ago

meetanubhav commented 6 years ago

2 Using web scrapping to get movie names

import requests
import bs4
import pandas as pd
rq = requests.get('https://www.imdb.com/chart/top') //I'm using https://imdb.com
bs = bs4.BeautifulSoup(rq.text , 'lxml')
bs.select('.titleColumn' )
lst = [i.text for i in bs.select('.titleColumn')]
print(lst)
lst1=[s.replace('\n', '') for s in lst] # remove all the \n
print(lst1)
Movies = pd.DataFrame(lst1 , columns = ['Movies'])
Movies
Movies.to_csv('Top250_movie_by_ratings.csv' , index = False)
"""Saved successfully as CSV file """