我想使用beautifulSoup从这个link得到学校名称,“珀金斯学院...”。从<a>元素获取文本?
我使用的代码不会返回任何内容。
school = soup.find('a','profiles-show-school-name-sm-link')
print 'school: ', school
print 'school.text: ', school.text
输出:
school: <a class="profiles-show-school-name-sm-link" href="/profiles/show/online-degrees/stephen-f-austin-state-university/perkins-college-of-education-undergraduate/395/5401">
<img border="0" src="/images/profiles/243x60/4613/degrees/undergraduate-certificate-in-hospitality-administration.png"/>
</a>
school.text:
建议一个BeautifulSoup实现提取校名(不是URL)?谢谢!
您是否在寻找一个美丽的实现来提取学校名称?如果你想获得href,我相信school ['href']会起作用。 – sihrc