如何抓取带有盲注的 table?
How to scrape a table with a blind caption?
我正在从页面上抓取 table。
但是 table 的标题是 'blind'。
没有办法从站点中提取 table 吗?
使用 BeautifulSoup 如:
from urllib.request import urllib
from bs4 import BeautifulSoup
看看这个:
import bs4 as bs
import urllib.request
link = 'http://companyinfo.stock.naver.com/v1/company/c1010001.aspx?cn=&cmp_cd=005930&menuType=block'
source = urllib.request.urlopen(link)
soup = bs.BeautifulSoup(source, 'html.parser')
table = soup.find('table', attrs={'id' : 'cTB24'})
for tr in table.find_all('tr'):
for td in tr.find_all('td'):
print(td.text)
我正在从页面上抓取 table。
但是 table 的标题是 'blind'。
没有办法从站点中提取 table 吗?
使用 BeautifulSoup 如:
from urllib.request import urllib
from bs4 import BeautifulSoup
看看这个:
import bs4 as bs
import urllib.request
link = 'http://companyinfo.stock.naver.com/v1/company/c1010001.aspx?cn=&cmp_cd=005930&menuType=block'
source = urllib.request.urlopen(link)
soup = bs.BeautifulSoup(source, 'html.parser')
table = soup.find('table', attrs={'id' : 'cTB24'})
for tr in table.find_all('tr'):
for td in tr.find_all('td'):
print(td.text)