6

Python爬虫编程思想(114):项目实战--使用Splash Lua抓取京东搜索结果

 2 years ago
source link: https://blog.csdn.net/nokiaguy/article/details/122446135
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(114):项目实战--使用Splash Lua抓取京东搜索结果

专栏收录该内容
117 篇文章 6 订阅 ¥29.90 ¥99.00

        本文会利用Splash Lua脚本在京东商城上搜索商品,然后抓取搜索出的商品名称,以及将每一页搜索结果的截图保存为PNG格式的文件。

        本例的核心是使用select_all方法通过CSS选择器得到搜索页面搜索出的每一个商品对应的a节点,然后获取a节点的title属性值。本例采用了Python与Lua结合的方式,也就是通过Python产生多个URL,然后用Lua脚本抓取每一个URL对应页面中的数据。

        下面的代码使用Python语言和Lua脚本在京东商城上以Python关键字进行搜索图书,并将返回找到的图书的标题,以及每一个搜索页面的截图。本例只抓取前6页的数据。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK