【发布时间】:2015-03-15 00:03:30
【问题描述】:
对于Fashiontrends.pk <dl class="boccat"> 包含所有链接。我们想编写一些代码来找到该部分,然后获取该部分的<dd> 元素中的所有链接。
from bs4 import BeautifulSoup
from urllib2 import urlopen
BASE_URL = "http://www.fashiontrends.pk"
def get_category_links(section_url):
html = urlopen(section_url).read()
soup = BeautifulSoup(html, "lxml")
boccat = soup.find("dl", "boccat")
category_links = [BASE_URL + dd.a["href"] for dd in boccat.findAll("dd")]
return category_links
【问题讨论】:
-
是的,您需要什么帮助?
-
该页面中没有 DL 标签..
标签: python beautifulsoup