1、Python很有名,但是一直没在实际项目中用过,今天花30分钟学习下。
去Python官网https://www.python.org/downloads/


2、2.X与3.X版本相差比较大,新手用最新的3.6.4。
3、下载安装。
4、安装BeautifulSoup,CMD进入C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\Scripts,运行 pip install bs4.
5、桌面建一个记事本test.py,去网上找例子,注意3.x与2.x语法不一样下面代码是3.x下可以使用的。

#!/usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import urllib.request
url = r'http://douban.com'
res = urllib.request.urlopen(url)
html = res.read().decode('utf-8')
html_doc = """
<html><head><title>The Dormouse's story</title></head>
<body>
<p class="title"><b>The Dormouse's story</b></p>
<p class="story">Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>,
<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;
and they lived at the bottom of a well.</p>
<p class="story">...</p>
""" #获取BeautifulSoup对象并按标准缩进格式输出,下面用html,或者html_doc一个是本地,一个是远程。
soup = BeautifulSoup(html,"html.parser")
print(soup.prettify())
print(soup.title)

6、右键Edit with IDE,Run、Run Moudle,输出结果了吧,入门就这么简单。

最新文章

  1. jQuery学习笔记(五)jQuery中的表单
  2. c++中的内存空间不足和自定义处理内存不足
  3. 《JavaScript权威指南》学习笔记 第二天 下好一盘大棋
  4. ios程序后台运行设置(不是太懂)
  5. Activiti 流程实例、任务、执行对象及相关的表
  6. PHP登陆Session验证
  7. Oracle 中 根据值 查询 所在 表和字段
  8. group_concat 长度限制,排序和设置分隔符
  9. 动态规划——H 最少回文串
  10. Easyui弹出窗体在iframe的父级页面显示
  11. 【最大流之sap】【HDU1532】模板题
  12. hadoop namenode -format Couldn&amp;#39;tload main class &amp;quot;-Djava.library.path=.home.hadoop.hadoop-2.5.2.lib&amp;quot;
  13. 有序线性表(存储结构数组)--Java实现
  14. Cookie、session和localStorage、以及sessionStorage之间的区别
  15. char数组中除去某个元素
  16. JAVA解析XML文件(DOM,SAX,JDOM,DOM4j附代码实现)
  17. linux内核中的排序接口--sort函数
  18. mysql获取连接connection失败
  19. vue day5 分页控件
  20. 模拟祭-比萨-题解O(n)

热门文章

  1. 软件工程_9th weeks
  2. 激活win10专业版
  3. python之多线程举例
  4. CSS实现垂直居中的5种思路
  5. [ctsc2018] 混合果汁 【可持久化线段树】【二分答案】
  6. TortoiseSVN 忽略文件 忽略已提交文件
  7. 通过 powershell 配置 IIS
  8. 洛谷 画栅栏Painting the Fence 解题报告
  9. 【codeforces 103E】 Buying Sets
  10. 利用快排partition求前N小的元素