爬取淘宝商品的价格(移动端网页)

目标:用python2.7爬取淘宝某个商品的价格,网页为移动端地址(较为简单)

商品地址:https://detail.m.tmall.com/item.htm?id=540834601226&ali_trackid=2:mm_47264828_7912395_26766209:1489394832_2k2_424328776&pvid=10_61.242.42.45_382_1489394661432&e=fUKgqr6lczhw4vFB6t2Z2ueEDrYVVa64K7Vc7tFgwiHjf2vlNIV67nrEZKsiGKnZFfrEfJ4hp2q4dirMVQVbKp2-glV3Gc2lJsvEW9UvVWr4hHd22KyMYA2bPpUSXCW1lrfKbc84rlc2Qoj3JCdsjj3cibTWWiUNaS6QPHsQmTiTd_qmLIqp6f4VewOGwH7gyevN7Rq1k8Qc1aSSSMarQ5uTMF_CK3SPsv2Y5ji4vlWGWoaaImWkGiahd3snNVYBUbfFrD-QO6UBJaBDItTJ5W9_eUsstdCk14pAHVTpLiOiZ-QMlGz6FQ&type=2&tkFlag=0




代码:

from urllib2 import urlopen

from bs4 import BeautifulSoup 

html = urlopen("https://detail.m.tmall.com/item.htm?id=540834601226&ali_trackid=2:mm_47264828_7912395_26766209:1489394832_2k2_424328776&pvid=10_61.242.42.45_382_1489394661432&e=fUKgqr6lczhw4vFB6t2Z2ueEDrYVVa64K7Vc7tFgwiHjf2vlNIV67nrEZKsiGKnZFfrEfJ4hp2q4dirMVQVbKp2-glV3Gc2lJsvEW9UvVWr4hHd22KyMYA2bPpUSXCW1lrfKbc84rlc2Qoj3JCdsjj3cibTWWiUNaS6QPHsQmTiTd_qmLIqp6f4VewOGwH7gyevN7Rq1k8Qc1aSSSMarQ5uTMF_CK3SPsv2Y5ji4vlWGWoaaImWkGiahd3snNVYBUbfFrD-QO6UBJaBDItTJ5W9_eUsstdCk14pAHVTpLiOiZ-QMlGz6FQ&type=2&tkFlag=0")

bsObj=BeautifulSoup(html)

nameList=bsObj.findAll("span",{"class":"mui-price-integer"})

 for name in nameList:

   print(name.get_text())




你可能感兴趣的:(python爬虫)