赞
踩
1 #coding=utf-8
2
3 importurllib24
5 from lxml importetree6
7 importre8
9
10 if __name__ == '__main__':11
12 main_url = """http://search.jd.com/Search?keyword=%%E6%%89%%8B%%E6%%9C%%BA&enc=utf-8&suggest=0#keyword=%%E6%%89%%8B%%E6%%9C%%BA&enc=utf-8&qrst=1&ps=addr&rt=1&stop=1&sttr=1&cid3=655&click=3- 655&psort=3&page=%s"""
13
14 page_num = 1
15
16 for page inrange(page_num):17
18 html_url = main_url %page19
20 Res =urllib2.urlopen(html_url)21
22 Htm =Res.read()23
24 #print Htm
25
26 tree =etree.HTML(Htm);27
28 #phone_names = tree.xpath("//div[@id='plist']/ul/li/div[@class='lh-wrap']/div[@class='p-name']/a/text()")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。