我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

初学python,爬取京东商品数据时无法获取内容

  1. import requests from lxml import html

def spider_JD(sn):
url = 'https://search.jd.com/Search?keyword={0}'.format(sn)
html_doc=requests.get(url).text
selector=html.fromstring(html_doc)
ul_list2=selector.xpath('//div[@id="J_goodsList"]/ul/li')
print(len(ul_list2))

if name=='__main__':
spider_JD('9787115428028')
图片说明
如图所示 可以看到很多li
但上述代码运行显示为0

近期文章

  • Get The Treasure 的问题
  • It's not a Bug, It's a Feature! 具体实现
  • Happy Birthday 的问题
  • Picture 怎么编写呢
  • Breweries 的问题
  • Summer Holiday 的实现问题
  • Horizontal and Vertical Rays 编写代码的思路
  • DLL文件包含自己生成的lib文件,编译错误
  • Jimmy’s Assignment 是怎么做的
  • Q-Sequence 的设计
  • 用一个最小的长方形框将所有点框在内的算法
  • EXCEL 排序
  • 统计一个给定字符串中指定的字符出现的次数
  • Digital Roots 的问题
  • Starship Troopers
  • The 3n + 1 problem
  • Delta-wave 的设计问题
  • Minimum’s Revenge 的问题
  • Rotate String 字符串的思路
  • Binary Indexed Tree 是怎么做的

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华