Coder Social home page Coder Social logo

royal-glory-hd-wallpaper's Introduction

                                          获取王者荣耀的高清壁纸

采用的方法: selenium+requests+BeautifulSoup 王者荣耀官方网站的url: https://pvp.qq.com/web201605/wallpaper.shtml

该网站的首页最下方会显示高清壁纸模块,共10页,分析得出,该网站图片的加载采用的为Ajax请求,所以有2种方法,selenium和分析请求2种方式.该脚本采用selenium 方式.思路是:先用selenium分别打开10个页面,打开一个页面后,待该页面加载完毕后,获取该页面的完整源码,最后将10页内容的源码合成一个字符串,用BeautifulSoup 方法进行解析,获取图片的url,然后用requests去请求图片的url,获取content(字节类型),然后用二进制的方式保存每个图片

该方法优点:思路明确,编写较为简便.分析接口方法有点难度,需要准确找到响应的请求,并解析请求的内容才可

该方法缺点:运行时间相比分析接口方法运行时间较长,主要是打开浏览器这个动作较为耗时

改进版:

  1.第一版在程序入口处使用了太多函数,看上去有点乱,不易理解及维护.第二版又封装了一些方法,使代码看上去更简洁,方便维护!
  
  2.使用了代码规范,使代码看上去更美观!

备注:pycharm使用快捷键:Shift+Ctrl+Alt+L,然后选择Whole file,点击OK,即可使代码变为规范形式!

royal-glory-hd-wallpaper's People

Contributors

hewenyi666 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.