直接用这段:给scrapy改个名字。中学生一看spider、domain、url 是吧,dna动了。
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class MySpider(CrawlSpider):
name = 'example.com'
allowed_domains = ['example.com']
start_urls = ['http://www.example.com']
rules = (
# Extract links matching 'category.php' (but not matching 'subsection.php')
# and follow links from them (since no callback means follow=True by default).
Rule(LinkExtractor(allow=('category\.php', ), deny=('subsection\.php', ))),
# Extract links matching 'item.php' and parse them with the spider's method parse_item
Rule(LinkExtractor(allow=('item\.php', )), callback='parse_item'),
)
缓冲 实用工具继承 调试实用工具 前置监听(不太确定),新建了名为字符串解码的变量 但是片段里没有使用
然后就是/* */是多行注释,//是单行注释,所以那些灰色的部分都是不执行的
代码
稍微有点追求的话,日本动画也是可以有一定技术水准的 https://bgm.tv/blog/275364
如果经费多一点,就可以做The Matrix 2里面的ssh漏洞。这个事情要怎么筹划,到CTF竞赛上面找几个参赛选手,录一下屏幕,素材就有了。
可以硬生生解释为胡桃的程序有几个依赖,然后这几个依赖长时间没有更新它自己的依赖,其中一个依赖(或者依赖的依赖)依赖了一个上古版本的 readable-stream,胡桃为了方便移植到别的地方不用重新安装依赖就把依赖全部打包到单文件里,而 commonjs 又没有 tree shaking,不管实际有没有用到这段代码全给你打进去, 然后打包完成后,胡桃想看看有没有问题 cat 了一下打包后的文件,然后正好屏幕显示了这段代码
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class MySpider(CrawlSpider):
name = 'example.com'
allowed_domains = ['example.com']
start_urls = ['http://www.example.com']
rules = (
# Extract links matching 'category.php' (but not matching 'subsection.php')
# and follow links from them (since no callback means follow=True by default).
Rule(LinkExtractor(allow=('category\.php', ), deny=('subsection\.php', ))),
# Extract links matching 'item.php' and parse them with the spider's method parse_item
Rule(LinkExtractor(allow=('item\.php', )), callback='parse_item'),
)
def parse_item(self, response):
self.logger.info('Hi, this is an item page! %s', response.url)
item = scrapy.Item()
item['id'] = response.xpath('//td[@nomoenomoe="item_id"]/text()').re(r'ID: (\d+)')
item['name'] = response.xpath('//td[@nomoenomoe="item_name"]/text()').get()
item['description'] = response.xpath('//td[@nomoenomoe="item_description"]/text()').get()
item['link_text'] = response.meta['link_text']
url = response.xpath('//td[@nomoenomoe="additional_data"]/@href').get()
return response.follow(url, self.parse_additional_page, cb_kwargs=dict(item=item))
def parse_additional_page(self, response, item):
item['additional_data'] = response.xpath('//p[@nomoenomoe="additional_data"]/text()').get()
return item