Home>

thisWikipedia pageI want to extract the contents of the award reason column from (all year) with bs4 of python.

NotImplementedError Traceback (most recent call last)
<ipython-input-27-9c2fd27fc558>in<module>()
---->1 table = soup.select ('tbody>tr>td: nth-child (3)')
      2
      3 # table.wikitable: nth-child (5)>tbody: nth-child (1)>tr: nth-child (2)>td: nth-child (3)
      4 print (table)
      Five 
2 frames
/usr/local/lib/python3.6/dist-packages/bs4/element.py in select (self, selector, _candidate_generator, limit)
   1526 else:
   1527 raise NotImplementedError (
->1528'Only the following pseudo-classes are implemented: nth-of-type.')
   1529
   1530 elif token =='*':
NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.
Corresponding source code
import requests, bs4
url ='https://ja.wikipedia.org/wiki/%E3%82%A4%E3%82%B0%E3%83%8E%E3%83%BC%E3%83%99%E3%83% AB% E8% B3% 9E% E5% 8F% 97% E8% B3% 9E% E8% 80% 85% E3% 81% AE% E4% B8% 80% E8% A6% A7'
res = requests.get (url)
# print (res)
soup = bs4.BeautifulSoup (res.text,'html.parser')
# print (soup)
table = soup.select ('tbody>tr>td: nth-child (3)')
What I tried

In Firefox's verification tool, the corresponding column is
'/ html/body/div [3]/div [3]/div [5]/div [1]/table [1]/tbody/tr [3]/td [2]'
I found that it is in

As it is

table = soup.select ('/ html/body/div [3]/div [3]/div [5]/div [1]/table [1]/tbody/tr [3]/td [2]')


Even as

Unsupported or invalid CSS selector: "/ html/body/div [3]/div [3]/div [5]/div [1]/table [1]/tbody/tr [3]/td [2]"


I get an error. (I found out that this is xpath now)
How can I enter css_path to extract the award reason content for the entire year?

Supplementary information (FW/tool version, etc.)

I'm trying to extract using Colaboratory.