Created
August 7, 2016 11:37
-
-
Save ramuta/a3e4b413cce71797d9ba8b9babf498de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from urllib2 import urlopen | |
from BeautifulSoup import BeautifulSoup | |
url = "https://en.wikipedia.org/wiki/Game_of_Thrones" | |
response = urlopen(url).read() | |
soup = BeautifulSoup(response) | |
table_soup = soup.findAll("table", attrs={"class": "wikitable"})[1] # find the second table in the article | |
print table_soup | |
print("---------------------------") | |
print table_soup.caption.a.string | |
print("---------------------------") | |
print table_soup.table.tr.th | |
print("---------------------------") | |
print table_soup.findAll("th") | |
print("---------------------------") | |
print table_soup.findAll("th")[1].small.a.string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment