Python crawler Ideas

Source: Internet
Author: User
Python2
Crawler: Take data from a webpage
Crawler module: URLLIB,URLLIB2,RE,BS4,REQUESTS,SCRAPY,XLML
1.urllib
2.request
3.bs4
4. Regular RE
5 Types of data
(1) Number
(2) Strings string
(3) List list[] Chinese in an iterative object is a Unicode object
(4) tuple tuples ()
(5) Dictionary set{}
Crawler ideas:
1. Static Urlopen Open the webpage------get the source read
2.requests (module) Get/post request----Get the source text () method content () method (recommended)
3.BS4 can parse HTML and XML
#- -Coding:utf-8--
From BS4 import BeautifulSoup
#1
#html = "<div>2018.1.8 14:03</div>"
#soup =beautifulsoup (HTML, ' Html.parser ') #解析网页
#print Soup.div
#2从文件中读取
Html= "
Soup=beautifulsoup (Open (' index.html '), ' Html.parser ')
Print soup.prettify ()
4. Get the information you need

Python crawler Ideas

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.