版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/haolipengzhanshen/article/details/88977987
ChildText是获取的子元素的文本内容
ChildAttr
一、parallel并发性
在并行化爬虫时,需要控制好MaxDepth爬取的深度以及设置Async
需要设置LimitRule限速规则
二、url_filter例子
url_filter的目的是什么,基于什么场景?
在创建Collector时,通过设置正则表达式,符合正则表达式的url链接才能进行再次访问。
c := colly.NewCollector(
扫描二维码关注公众号,回复:
6000865 查看本文章
// Visit only root url and urls which start with "e" or "h" on httpbin.org
colly.URLFilters(
regexp.MustCompile("http://httpbin\\.org/(|e.+)$"),
regexp.MustCompile("http://httpbin\\.org/h.+"),
),
)
更加节约了cpu资源以及存储空间和计算
三、shopify_sitemap例子,直接解析xml内容的节点
xpath语法
http://www.w3school.com.cn/xpath/xpath_syntax.ASP
xpath使用路径表达式在xml文档中选取节点。节点是通过沿着路径或step来选取的。
四、request_context例子
在request和response之间传递上下文参数
五、爬虫代理proxy_switcher