【发布时间】:2020-03-25 14:59:35
【问题描述】:
我想在这个维基百科page 中用多伦多的邮政编码刮桌子。
无论我使用 pandas 方法或 beautifulSoup,它都不起作用,尽管其他人报告它应该起作用。恳请您提供您的提示:
熊猫:
df = pd.read_html('https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M')[0]
美丽的汤:
根据其他人的说法,使用图像中代码的输出表应该是图像中的表'expexted output with beautifulSoup'
beautifulSoup 的输出
beautifulSoup 的预期输出
【问题讨论】:
-
不确定
pandas是否有神奇的方法,但你为什么不这样刮:for each td in for each tr, postal code = text inside <p>, if not <a> in <span> status = not_assigned else borough: text in first <a>, neighborhood: text in second <a>
标签: python pandas beautifulsoup