zoukankan      html  css  js  c++  java
  • 模拟登陆github

    目的:模拟登陆github
    工具:scrapy shell ,from scrapy.http import FormRequest

    流程:通过解析github登陆页面https://github.com/login
    利用chrome开发者工具截取信息
    1.先在登陆页面输一次账号密码,在表单里得到需要输入的参数,如图
    在这里插入图片描述
    再结合页面的输入框,可知我们需要提交的表单要包含五个参数,其中需要我们人工输入的参数是1.login 2.password
    2.接下来我们在cmd里输入个

    scrapy shell https://github.com/login
    

    接着

    >> from scrapy.http import FormRequest 
    

    接下来我们构造表单

    >>fd={'login':'XXXXXX','password':'XXXXXX'}
    >>request=FormRequest.from_response(response,formdata=fd)  
    

    上一个代码块利用了FormResponse的from_response方法来从response中解析出我们要提交的三个隐式参数并帮我们自动加入了表单,这样我们就完成了模拟登陆
    我们可以用

    fetch(request)
    

    查看返回状态

    view(response)
    

    可以帮我们查看页面

  • 相关阅读:
    racket eval
    mex不兼容
    【转】雷军 程序员随想
    UBoot 目录结构和编译过程
    远程监控web开发
    STL容器[08]
    STL容器[07]
    STL容器[17]
    STL容器[06]
    stl.map使用总结
  • 原文地址:https://www.cnblogs.com/yfc0818/p/11072694.html
Copyright © 2011-2022 走看看