当前位置:   article > 正文

python爬取京东手机数据_python爬虫系列之爬京东手机数据

python爬取京东手机数据

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()")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/384554
推荐阅读
相关标签
  

闽ICP备14008679号