Life is too Short Crawler crawl Web page of the General code framework

Source: Internet
Author: User

We first open the Idle Select file->new Window command (or you can directly press CTRL + N, in many places this button is the new file meaning)

Here is still to recommend my own built Python development Learning Group: 725479218, the group is the development of Python, if you are learning Python, small series welcome you to join, everyone is the software Development Party, not regularly share dry goods (only Python software development-related), Including a copy of my own. 2018 Latest Python Advanced materials and high-level development tutorials, welcome to the next step and into Python's small partners

We fill in the code:

Save the file is the key shortcut key Ctrl+s, save the source code as a hello.py file

Press F5 to run (and we can choose the Run->run Module command).

An error appears in idle :

The reason is that the name 'name' is undefined

Note: You need a long underline here to make it correct, to distinguish the syntax of the python itself

After the correction we run again:

We saw the same results as before.

We'll modify the Web connection to see what happens:

The result is "produce an exception"

Explain the generic code framework: The GET method requests a link that r.raise_for_status to determine whether the request is normal (that is, 200), otherwise an exception is generated. r.encoding = r.apparent_encoding This sentence is able to be our request to return the page decoding is correct, and finally return the content of the page.

This framework is used to solve the problem of our visiting the webpage.

Today's content is this, a little bit every day, the heavy insist. Come on!!!

Life is too Short Crawler crawl Web page of the General code framework

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.