Share Tutorial: Search for images in the site and check for invalid images.

Source: Internet
Author: User

Currently in the group test new students often do not know how to learn their own coding knowledge and test scenarios actually combined, here take 1 practical examples, analysis of the process.

    • Get 1 Test requirements that need to be coded, how to do it

Testing requirements: The company's website is a lot of product images are invalid links, check the search out, for further processing.

First, think: What do you want to do next?

    1. Idea: Search out all image links-----> Access these links to view response-------> HTTP Code non 200 for invalid links
    2. What language: The current popular language Java,python, can do, finally choose Python, processing similar crawler work, Python is relatively simple and convenient, and a lot of libraries.
    3. Do not know the Python library: View the Classic library HTTPS://GITHUB.COM/JOBBOLE/AWESOME-PYTHON-CN, find processing HTTP requests, or direct Baidu/google search python URL

Second, how to find all the pictures in the site link

  1. Open the company's Web site, right----to view the site source code, will come out a lot of HTML code; We're just going to link the images inside.
  2. Code: Output The source code of the website to buffer, and then proceed with it.
       
  3. View the picture link inside: You can observe the main form of the picture link: style= "width:100%" src= "/http Zcy-item.img-cn-hangzhou.aliyuncs.com//2017062111022565214060.png ">
  4. Search by Regular expression: ""
  5. Code
    Import re# Regular expression module imagelist = Re.findall (R "" "
    Output: [' http://zcy-item.img-cn-hangzhou.aliyuncs.com//2017060816344209047406.png ', '/HTTP Zcy-item.img-cn-hangzhou.aliyuncs.com//2017111717221734892422.gif ' ... ]

  6. Not to be continued

Share Tutorial: Search for images in the site and check for invalid images.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.