利用lamda函数 的函数式编程 实现scrapy审计外网安全问题
生活随笔
收集整理的這篇文章主要介紹了
利用lamda函数 的函数式编程 实现scrapy审计外网安全问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
import scrapy from scrapy.spiders import Spiderdef parse_response(response, ip_in):title = response.xpath("/html/head/title").extract()[0]filename = 'quotes.txt'with open(filename, 'a+') as f:f.write(response.request.url + ' ' + title + ' ' + ip_in + '\n')print(response.request.url + ' ' + title + ' ' + ip_in + '\n')class dmozSpider(Spider):name = 'dmoz'def start_requests(self):filename = 'quotes.txt'with open(filename, 'w') as d:d.write("")f = open("dns.txt")for line in f.readlines():line = line.strip('\n')url = line.split()[0] + '.baidu.com'ip = line.split()[1]print(url + ' ' + ip)yield scrapy.Request(url='http://' + url, callback=lambda response, ip_in=ip: parse_response(response, ip_in))# for url in urls:yield scrapy.Request(url='https://' + url, callback=lambda response, ip_in=ip: parse_response(response, ip_in))?
轉載于:https://my.oschina.net/9199771/blog/1935313
總結
以上是生活随笔為你收集整理的利用lamda函数 的函数式编程 实现scrapy审计外网安全问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 进程池的用法
- 下一篇: p批处理替换目录下文本中的字符串