2017-03-21 4 views
1

私は4つのURLを持っています...私はURLのスリーブの詳細が必要です。スリーブの詳細な変更位置とそれによって保存されているノードも変更されます...最初のURLはスリーブが2番目の位置です他の3つのURLのスリーブは第三position..Iにある以下美しいスープを使って特定のノードを名前で取得する必要がありますか?

URLS                          Sleeves 
http://www.jabong.com/belle-fille-Green-Solid-Winter-Jacket-1310755.html?pos=5&cid=BE797WA44OZRINDFAS Full Sleeves 
http://www.jabong.com/oxolloxo-Off-White-Solid-Reversible-Blazer-2687327.html?pos=8&cid=OX344WA72XITINDFAS Long Sleeve 
http://www.jabong.com/oxolloxo-Multicoloured-Checked-Blazer-2784283.html?pos=16&cid=OX344WA16KTVINDFAS 3/4th Sleeves 
http://www.jabong.com/mirika-Blue-Embellished-WINTER-JACKET-2754538.html?pos=19&cid=MI137WA61STUINDFAS Sleeveless 

...以下のように出力を必要とするコードの私の一部です:

for 1st url : soup.find_all("span", {"class":"product-info-left"})[1].next_sibling.text 

for 2nd to 4th url : soup.find_all("span", {"class":"product-info-left"})[2].next_sibling.text 

答えて

1
soup.find("span", text="Sleeves").next_sibling.text 
0

あなたが唯一のこれらの文字列を見つけることができますこれらは、'Sleeve'を含む。機能チェックこのlinkを使用してフィルタリングを学ぶために

def check(text): 
    return type(text) != type(None) and text.find('Sleeve') > -1 

sleeves = soup.find_all(string=check) 
print(sleeves[1]) 

出力

Full Sleeves 
Long Sleeve 
3/4th Sleeves 
Sleeveless 

関連する問題