项目一:唯一图库

项目概述:根据需要到唯一图库爬取图片

所用技术:scrapy,urllib,字符串处理,百分号格式化

爬虫程序根据setting和item配置把爬取到的数据交给pipline处理

相关操作记录如下:

唯一图库爬取图片

爬虫程序

 1 #!/usr/bin/env python
 2 #-*- coding:utf-8 -*-
 3 #s1.py
 4 import scrapy
 5 from scrapy.selector import HtmlXPathSelector
 6 from spider1 import items
 7 
 8 class LL(scrapy.spiders.Spider):
 9     name = 'xx'
10     start_urls=['http://www.mmonly.cc/sgtp/',]
11     def parse(self,response):
12         hxs = HtmlXPathSelector(response)
13 
14         item = items.Spider1Item()
15         item['names'] = hxs.select('//div[@class="item_t"]//img/@alt').extract()
16         item['imgs'] = hxs.select('//div[@class="item_t"]//img/@src').extract()
17         yield item
View Code

相关文章:

  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-01-07
  • 2021-10-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2021-11-24
  • 2022-02-16
  • 2021-04-28
相关资源
相似解决方案