📌  相关文章
📜  在特定的 div 标签中查找链接 beautifulsoup - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:33.041000             🧑  作者: Mango

代码示例1
import urllib2
from BeautifulSoup import BeautifulSoup

url = "http://www.gsmarena.com/samsung-phones-f-9-0-p2.php"
text = urllib2.urlopen(url).read()
soup = BeautifulSoup(text)

data = soup.findAll('div',attrs={'class':'makers'})
for div in data:
    links = div.findAll('a')
    for a in links:
        print "http://www.gsmarena.com/" + a['href']