w3resource

Python Web Scraping: List all language names and number of related articles in the order they appear in wikipedia

Python Web Scraping: Exercise-12 with Solution

Write a Python program to list all language names and number of related articles in the order they appear in wikipedia.org.

Sample Solution:

Python Code:

from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen('https://www.wikipedia.org/')
bs = BeautifulSoup(html, "html.parser")
nameList = bs.findAll('a', {'class' : 'link-box'})
for name in nameList:
  print(name.get_text())
  
 

Sample Output:

English
5 675 000+ articles


日本語
1 111 000+ 記事


Español
1 427 000+ artículos


Deutsch
2 195 000+ Artikel


Русский
1 481 000+ статей


Français
1 997 000+ articles


Italiano
1 446 000+ voci


中文
1 012 000+ 條目


Português
1 000 000+ artigos


Polski
1 288 000+ haseł

Flowchart:

Python Web Scraping Flowchart: List all language names and number of related articles in the order they appear in wikipedia.org.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python program to check whether a page contains a title or not.
Next: Write a Python program to get the number of people visiting a U.S. government website right now.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/web-scraping/web-scraping-exercise-12.php