Last time I learned how to crawl a picture on a Web page with Python, I'm going to learn how to use Python to get what we're interested in on the web.
Objective: To crawl the article title, link, reading quantity, comment number and collection
#! /usr/bin/env python #coding =utf-8 import urllib2 from BS4 import beautifulsoup import re import datetime import Rand Om pages=set () random.seed (Datetime.datetime.now ()) #Retrieves a list of all Internal the links found on a page def Getintern
1. Simple situation
There are two main ways to import packages and modules in Python:
(1) Import Package.module
(2) from package Import module
After the module is imported into the current program, the corresponding properties in module attr are
In the project, the words in the whitelist need to be extracted from the stem.
Whitelist may be as follows:
Sissied
Loveed
Mianmianies hit
Mut had
Because the white list may be a word or a phrase, and some words may be three-form,
Grayscale Features
The code is as follows:
def img2cols (Self, img):
img = Img.reshape (img.size, order= "C")
# Convert the data type as Np.float64
img = IM G.astype (np.float64) return
img
Hog Features
The code is as follows:
* * output picture
**Import the CV2 package in OpenCV, and then have functions like imread,imshow to read and display the picture.
Cv2.waitkey (0) to keep the window, waiting for the keyboard input, if the keyboard does not enter, it will always
Floating 1.1 Floating Introduction
Element can be set to float left or right (does not jump out of the parent element's width)
When an element floats, it is detached from the document stream (affecting subsequent elements)
Once the
1.JSON Sequence Description: Provides 4 keywords: dumps,dump,loads,load (exactly the same as the pickle usage)Syntax: F.write (bytes (Json.dumps (dict), encoding= "Utf-8"))R=json.loads (F.read (). Decode ("Utf-8"))The dictionary is stored in a file
In Python, there are usually 3 types of comments, namely "single line Comment", "multiline comment", "Chinese code declaration note""Chinese Code declaration notes"The appearance of the annotation is mainly to solve the problem that the python2.x
First, the Python installation preparation PythonDutch Guido van Rossum,2005 joins Dropbox for google,2013 year1989, the creation of the Python language, in early 1991 released the first public release versionPython philosophy>>> Import thisThe Zen
1 Python provides a variety of process communication methods, mainly queue and pipe in two ways, queue for multiple processes to achieve communication, pipe is two processes of communication 1.1 queue has two methods:
Put method: To insert
Backup files:#Enter the name of the file to be copied (with suffix)Old_file_name = input ('Please enter the file name you want to copy:')#Open the file you want to copyF_read = open (Old_file_name,'R')#New file nameA = Old_file_name.rfind ('.')"
Placeholder, as the name implies is inserted in the output of the symbol of the position. We can interpret it as our hotel reservation. When we tell the hotel, the hotel's system will have our booking location. Although we did not go now, but later
Qt is a cross-platform C + + graphical user Interface application Development framework developed by QT Company in 1991. It can either develop GUI programs or be used to develop non-GUI programs, such as console tools and servers. Let's start by
Django Template Inheritance--20180123
A.include Template Tags
B.extend (inheritance) template label
-- include template label This tag allows the content of other templates to be included in the (template). The parameter of the
Design Patterns
Design pattern is the summary and refinement of predecessors ' work, usually, the design pattern that is widely circulated is a mature solution for a specific problem.
Use design patterns to reuse code, make code easier
Git:https://github.com/linyi0604/computer-vision1 #Coding:utf82 3 ImportCv24 ImportNumPy as NP5 6 #Create a black blank image of 200*2007img = Np.zeros ((dtype=),np.uint8)8 #Place a 100*100 white square in the center of the image9img[50:150, 50:150]
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