Scrape

Scrape

Winter Lv4

本文使用的颜色较多,开启夜间模式阅读效果更好


本系列主要是对阅读了python网络编程相关的总结与回顾

  1. 背景知识

    1. http简介

      url : 统一资源定位符 格式如下 []代表可省略
      protocol ://[username:password@] hostname[:port] / path / [;parameters][?query]#fragment
      protocol : 协议 主要有 http,https,ftp,sms,
      username,password : 主要ftp
      hostname : 主机名也就是域名 也可以用DNS映射得到IP地址,有一级二级域名之分
      port : 端口号 http默认是80 类似还有https 443 属于套接口
      path : 路径 就是位于主机中的地址
      parameters : 附加信息 现在用的少了
      query : 查询,多个查询就用&分开,GET请求参数里也有
      fragment : 片段 资源的补充 似乎很少使用
      http基本转向https 基于SSL socket相关也是爬取的主要内容

    2. http请求过程

      使用F12 Network 监听 Ctrl+R
      Status : 状态码就是404 403 200 类似的
      Initiator : 请求源 标记请求是由哪个进程或对象发起的
      Request请求方法 请求头 请求体
      Request Method : 请求方法GET POST居多 还有PUT DELETE 很多





      3. **<font color=azure>Scrapy</font>**
                    1. Xpath syntax 用在我们的xml 文件里面 便于快速提取所需要的性质 /  // [] (predicates)
                    2. Xml treated like tree of nodes 
                    3.  [一个教程网站](https://docs.scrapy.org/en/latest/intro/tutorial.html)
                    4. scrpay 的使用 基本教程都有  注意就是 有自己的内建命令 自己的脚本 不要出错了
                    5. getall()  get()第一个元素 [0].get() title::text 仅仅要文本时候 re() 用正则表达式寻找
                    6.  除此之外还有  xpath的方法 response.xpath("//title")
                    7. [scrapy](https://docs.scrapy.org/en/latest/intro/tutorial.html)
                    8. 在我们 的 html 文件里面一个这个<><> 叫做一个 quote
                                  1.  -O 会覆盖当前文件 -o 就是append模式
                                  2.  用 jsonl 文件格式  可以不断添加 stream-like
      
  • Post title:Scrape
  • Post author:Winter
  • Create time:2023-03-22 21:13:13
  • Post link:https://spikeihg.github.io/2023/03/22/Scrape/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
if (hexo-config('comment.enable') == true && hexo-config('comment.use') != "") { if (hexo-config('comment.use') == "waline") { @require "./waline.styl" } else if (hexo-config('comment.use') == "gitalk") { @require "./gitalk.styl" } else if (hexo-config('comment.use') == "twikoo") { @require "./twikoo.styl" } } .comments-container { display inline-block margin-top $spacing-unit width 100% #comment-anchor { width 100% height 10px } .comment-area-title { width 100% margin 10px 0 font-size 1.38rem color var(--default-text-color) font-family "Noto Sans", "Noto Sans SC",sans-serif font-weight bold i { color var(--default-text-color) } +redefine-tablet() { margin 5px 0 font-size 1.2rem } } }