Python uses a proxy to capture website images (multithreading)

Source: Internet
Author: User
As a powerful scripting language, Python is often used to write crawler programs. The following describes how to use Python to capture images through multiple threads through a proxy. this is a simple python multi-thread crawler. I. function description:
1. capture the proxy server in multiple threads and verify the proxy server in multiple threads
The ps proxy server is crawled from the http://www.cnproxy.com/(the test selects only 8 pages)
2. capture the image address of a website and use multiple threads to randomly download images from a proxy server.
II. implementation code

The code is as follows:


#! /Usr/bin/env python
# Coding: UTF-8

Import urllib2
Import re
Import threading
Import time
Import random

RawProxyList = []
CheckedProxyList = []
Imgurl_list = []

# Crawling proxy websites
Portdicts = {'V': "3", 'm': "4", 'A': "2", 'L': "9", 'Q ': "0", 'B': "5", 'I': "7", 'w': "6", 'r': "8", 'C ': "1 "}
Targets = []
For I in xrange (1, 9 ):
Target = r "http://www.cnproxy.com/proxy%d.html" % I
Targets. append (target)
# Print targets

# Capture proxy server regular expressions
P = re. compile (r '''(. + ?)

Related Article

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.