Skip to content

Commit f425068

Browse files
authored
Scraping headings for any page in Wikipedia
1 parent 41b7ee6 commit f425068

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ml_wiki.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import bs4
2+
import requests
3+
import lxml
4+
5+
6+
res=requests.get('https://en.wikipedia.org/wiki/Machine_learning')
7+
soup=bs4.BeautifulSoup(res.text, 'lxml')
8+
# for i in soup.select('.mw-headline'):
9+
# print(i.text)
10+
for i in soup.select('.toctext'):
11+
print(i.text)

0 commit comments

Comments
 (0)