01 2020 档案
摘要:1. 股票数据定向爬虫 https://gupiao.baidu.com/stock http://quote.eastmoney.com/stock_list.html 2. 实例编写 2.1 获取HTML页面 def getHTMLText(url): try: r = requests.get
阅读全文
摘要:1. 淘宝商品信息定向爬虫 链接: https://www.taobao.com/ 2. 实例编写 2.1 整体框架 # -*- coding: utf-8 -*- import requests import re def getHTMLText(url): print("") # 对获得的每个页
阅读全文
摘要:1. 代码 # -*- coding: utf-8 -*- """ Created on Thu Jan 30 01:27:38 2020 @author: douzi """ import requests from bs4 import BeautifulSoup import bs4 def
阅读全文
摘要:1. format (1)设置对齐方式 (< (默认)左对齐、> 右对齐、^ 中间对齐、= (只用于数字)在小数点后进行补齐) print("{:<6} is {}".format('123', 'abcd')) # 左对齐 print("{:>6} is {}".format('123', 'ab
阅读全文
摘要:1. 中国大学排名定向爬虫 网站:http://www.zuihaodaxue.com/zuihaodaxuepaiming2016.html 查看源代码,发现信息直接写在HTML里的,即该定向爬虫可以实现 2. 程序的结构设计 2. 实例编写 2.1 代码总框架 # -*- coding: utf
阅读全文
摘要:1. 正则表达式 https://www.cnblogs.com/douzujun/p/7446448.html 单词边界的用法(非常好用啊!!!) 比如,我只想替换 app 为 qq,不像替换掉 apple和application里的app re.findall(r'\b\d{3}\b', '11
阅读全文
摘要:1. 基于bs4库的HTML内容查找方法 1.1 <>.find_all() 和 re (正则表达式库) (1)参数为单一字符串 (2)参数为 列表 (3)参数为True,则返回所有标签内容 (4)显示 以 b 开头的标签,如 b,body。(使用 re:正则表达式库) import request
阅读全文
摘要:1. 信息提取的一般方法 1.1 方法一 1.2 方法2 1.3 方法3 2. 实例 import requests from bs4 import BeautifulSoup r = requests.get("http://python123.io/ws/demo.html") demo = r
阅读全文
摘要:官网下载好anaconda,然后 bash Anaconda3-5.2.0-Linux-x86_64.sh 安装时候,需要输入的地方输入yes,然后一路回车: 安装完成,打开 .bashrc文件,添加把 export xxxx 写到最后一行,保存 sudo gedit ~/.bashrc expor
阅读全文
摘要:1. 信息标记 2. 信息标记种类 2.1 XML 举例: 2.2 JSON 2.3 YAML 3. 三种信息标记形式比较
阅读全文
摘要:1. prettify() import requests from bs4 import BeautifulSoup r = requests.get("http://python123.io/ws/demo.html") demo = r.text print(demo, "\n") soup
阅读全文
摘要:1. 基于bs4库的HTML内容遍历方法 1.1 .contents 举例 1.2 结点的父亲标签 1.3 标签树的上行遍历(parents) 1.4 标签树的平行遍历 注意:标签的儿子结点可能是 NavigableString
阅读全文
摘要:1. Beautiful Soup安装 pip install beautifulsoup linux要用 pip3 2. 使用 使用这个网站:https://python123.io/ws/demo.html # -*- coding: utf-8 -*- """ Created on Tue J
阅读全文
摘要:http://m.ip138.com/ import requests url = "http://m.ip138.com/ip.asp?ip=" r = requests.get(url + "202.204.80.112") print(r.status_code) print(r.text[-
阅读全文
摘要:1. 网络图片爬取 import os import requests root = ".//" url = "https://img2018.cnblogs.com/i-beta/817161/202001/817161-20200116224428592-123074215.png" path
阅读全文
摘要:1. cookie和session区别 2. 爬虫处理cookie和session 3. 处理cookies和session请求 4. 尝试使用session登录人人网(别试,了解一下) # -*- coding: utf-8 -*- import requests session = reques
阅读全文
摘要:1. requests模块发送post请求 # -*- coding: utf-8 -*- """ Created on Sun Jan 19 01:26:05 2020 @author: douzi """ # -*- coding: utf-8 -*- import requests impor
阅读全文
摘要:1. requests库安装 推荐使用anaconda,自带 2. requests使用 import requests r = requests.get("http://www.baidu.com") print(r.status_code) r.encoding = 'utf-8' print(
阅读全文
摘要:1. 字符串知识点 2. HTTP和HTTPS 3. url的形式 4. HTTP请求格式 5. GET和POST两种基本请求方法的区别 (1)GET把参数包含在URL中,POST通过request body传递参数。 (2)GET请求在URL中传送的参数是有长度限制的,而POST没有(大文本)。
阅读全文
摘要:6ZUMD7WWWU-eyJsaWNlbnNlSWQiOiI2WlVNRDdXV1dVIiwibGljZW5zZWVOYW1lIjoiSmV0cyBHcm91cCIsImFzc2lnbmVlTmFtZSI6IiIsImFzc2lnbmVlRW1haWwiOiIiLCJsaWNlbnNlUmVzdHJ
阅读全文
摘要:1. Git简介 2. 版本创建 2.1 安装 sudo apt-get install git 2.2 创建一个版本库 (1)创建一个目录git_test,在git_test目录下创建一个版本库,命令: git init (2)在git_test目录下创建一个文件code.txt,编辑内容如下:
阅读全文
摘要:使用
阅读全文