<jupyter_start><jupyter_text>1.Scrape the details of most viewed videos on YouTube from Wikipedia:Url= https://en.wikipedia.org/wiki/List_of_most-viewed_YouTube_videosYou need to find following details:A) RankB) NameC) ArtistD) Upload dateE) Views<jupyter_code>#Connect to web driver
driver=webdriver.Chrome(r"D://chromedriver.exe")  #r converts string to raw string
#If not r, we can use executable_path = "C:/path name"
#Getting the website to driver
driver.get('https://en.wikipedia.org/wiki/List_of_most-viewed_YouTube_videos')

#When we run this line, automatically the webpage will be opened
#Creating the empty lists to store the scraped data
Rank=[]
Name=[]
Artist=[]
Views=[]
Upload_Date=[]

#As we need only the first 30 details, we will iterate only for first 30 data
#Scrapping the details of the Rank of the video
rank=driver.find_elements_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']/tbody/tr/td[1]")
for i in rank[:30]:
    Rank.append(i.text)
    
#Scrapping the details of the video name
video=driver.find_elements_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']/tbody/tr/td[2]")
for i in video[:30]:
    Name.append(i.text)
    
#Scrapping the details of the Artist name
artist=driver.find_elements_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']/tbody/tr/td[3]")
for i in artist[:30]:
    Artist.append(i.text)
    
#Scrapping the details of the views information
views=driver.find_elements_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']/tbody/tr/td[4]")
for i in views[:30]:
    Views.append(i.text)
    
#Scrapping the details of the upload date
date=driver.find_elements_by_xpath("//table[@class='wikitable sortable jquery-tablesorter']/tbody/tr/td[5]")
for i in date[:30]:
    Upload_Date.append(i.text)
#Checking the length of the data scraped
print(len(Rank),len(Name),len(Artist),len(Views),len(Upload_Date))
#Creating a dataframe for storing the scraped data
Yt_data=pd.DataFrame({})
Yt_data['Rank']=Rank
Yt_data['Video Name']=Name
Yt_data['Artist']=Artist
Yt_data['Views(Billions)']=Views
Yt_data['Upload Date']=Upload_Date
Yt_data
#Removing the stray numbers from videoname
new=Yt_data["Video Name"].str.split("[", n = 1, expand = True) 
new
#Dropping the column with stray numbers
Yt_data.drop(columns=['Video Name'],axis=1,inplace=True)
#Inserting the name column
Yt_data.insert(1,"Video Name",new[0])

#Checking the data after removing the stray numbers
Yt_data  
#Closing the driver
driver.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12657728706624605, 'fraction_numerical': 0.00946372239747634, 'mean_word_length': 6.186968838526912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '477408', 'license': 'MIT', 'n_tokens_mistral': 892, 'n_tokens_neox': 858, 'n_words': 231, 'path': 'Webscraping/Wikipedia/Wikipedia_YoutubeData_Webscraping.ipynb', 'repo_name': 'Jerish7/FlipRoboTechnologies-Internship', 'size': '2536'}