【发布时间】:2017-05-24 15:42:09
【问题描述】:
当我被困在如何抓取网页中的每个链接(页面或子页面)并找到任何单词的频率时,我寻求帮助。我用了漂亮的汤 刮,但我不认为我做对了。例如:我需要进入 Service now 官方页面 > 解决方案 > 查看所有解决方案。并在查看所有解决方案下的所有链接/子页面中找到“智能”的频率。 任何帮助将不胜感激。 谢谢你:)
我的代码
import requests
from bs4 import BeautifulSoup
url = "https://www.servicenow.com/solutions-by-category.html"
serviceNow_r = requests.get(url)
sNow_soup = BeautifulSoup(serviceNow_r.text, 'html.parser')
print(sNow_soup.find_all('href',{'class':'cta-list component'}))
for name in sNow_soup.find_all('href',{'class':'cta-list component'}):
print(name.text)
【问题讨论】:
标签: python beautifulsoup