缺少汤对象的链接

时间:2015-09-21 07:05:03

标签: beautifulsoup

此代码将提取所有亚马逊链接。但是页面上有1个链接(可能不止一个)未显示在结果中。

http://www.amazon.com/gp/product/B00A0GTA00/ref=pd_lpo_sbs_dp_ss_3?pf_rd_p=1944687522&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=B001U2EQKC&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=1PZMRM5X5FR2ZW2E8EGZ

myurl='http://www.apartmenttherapy.com/11-everyday-items-under-25-everyone-needs-at-home-223494?utm_source=RSS&utm_medium=feed&utm_campaign=Category%2FChannel%3A+Main'

import urllib2
import BeautifulSoup

request = urllib2.Request(myurl)
response = urllib2.urlopen(request)
soup = BeautifulSoup.BeautifulSoup(response)
for a in soup.findAll('a'):
  if 'amazon' in a['href']:
    print a['href']

如何确保显示所有亚马逊链接?

0 个答案:

没有答案