python爬虫速成代码笔记
【Python爬虫编程基础5天速成(2021全新合集)Python入门+数据分析-哔哩哔哩】https://b23.tv/n0Qetn
橙黄橘绿时_Eden
在读硕士
展开
-
【8】保存数据到SQLite
保存数据到SQLite更新时间:2021.9.17vedio:27# -*- codeing = utf-8 -*-# @Time : 2020/3/3 17:51# @Author : 李巍# @File : spider.py# @Software: PyCharmfrom bs4 import BeautifulSoup # 网页解析,获取数据import re # 正则表达式,进行文字匹配import urllib.request, urllib.error # 制定UR原创 2021-09-17 13:35:14 · 327 阅读 · 0 评论 -
【7】补充SQLite(连接、创建、插入、查询)
补充SQLite(连接、创建、插入、查询)更新时间:2021.9.16vedio:26# -*- coding: utf-8 -*-# @Time : 2021/9/9 16:18# @Author : 李新宇# @FileName: testsqlite.py# @Software: PyCharmimport sqlite3#1.连接数据库# conn = sqlite3.connect("test.db") #打开或创建数据库文件## print("Opened原创 2021-09-16 20:48:53 · 582 阅读 · 0 评论 -
【6】爬虫介绍/准备工作/构建流程/获取数据/BeautifulSoup/Re(正则表达式)/正则提取/标签解析/保存数据到excel
爬虫介绍/准备工作/构建流程/获取数据/BeautifulSoup/Re(正则表达式)/正则提取/标签解析/保存数据到excel更新时间:2021.9.16vedio:15,16,17,18,19,20,21,22,23*# -*- coding: utf-8 -*-# @Time : 2021/9/4 18:33# @Author : 李新宇# @FileName: t1.py# @Software: PyCharmdef add(a,b): return a+bpr原创 2021-09-16 18:57:27 · 192 阅读 · 0 评论 -
【5】文件操作/异常处理
文件操作/异常处理更新时间:2021.9.3vedio:13,14# -*- coding: utf-8 -*-# @Time : 2021/9/3 10:52# @Author : 李新宇# @FileName: demo2.py# @Software: PyCharm'''f = open("text.txt","w")#打开文件,w模式文件不存在就新建f.write("hellow")f.close() #关闭文件'''''' #read方法,读取指定的字符原创 2021-09-03 13:42:38 · 111 阅读 · 0 评论 -
【4】函数定义/调用/全局or局部变量
函数定义/调用/全局or局部变量更新时间:2021.9.3# -*- coding: utf-8 -*-# @Time : 2021/9/3 9:16# @Author : 李新宇# @FileName: demo1.py# @Software: PyCharm'''#函数的定义def printinfo(): print("----------------------------") print("李新宇加油!") print("-------------原创 2021-09-03 13:39:57 · 98 阅读 · 0 评论 -
【3】元组_字典(上、下)and 集合
元组_字典(上、下)and 集合更新时间:2021.9.2vedio:10,11# -*- coding: utf-8 -*-# @Time : 2021/9/2 20:22# @Author : 李新宇# @FileName: demo5.py# @Software: PyCharm'''#元组的定义tup1 = () #创建空的元组# tup2 = (50) #<class 'int'>tup2 = (50,50,40)print(type(tup2))原创 2021-09-02 22:04:39 · 69 阅读 · 0 评论 -
【2】字符串/列表上/列表下
字符串/列表上/列表下更新时间:2021.9.2vedio:7,8,9# -*- coding = utf-8 -*-# @Time : 19:26# @Author : 李新宇# @File : demo4.py# @Software : PyCharm# namelist = [] #定义一个空的列表# namelist = ["qqq","www","eee"]'''testlist = [1,"测试"]print(testlist[0])print(testlist[原创 2021-09-02 22:02:08 · 63 阅读 · 0 评论 -
【1】条件判断/循环控制
更新时间:2021.9.2# -*- coding = utf-8 -*-# @Time : 15:15# @Author : 李新宇# @File : demo3.py# @Software : PyCharm'''if True: print("true")else: print("false")'''score = 50'''if score >= 90 and score <= 100 : print("本次考试等级为A")eli原创 2021-09-02 21:56:24 · 57 阅读 · 0 评论 -
【0】第一个Python程序
格式化输出更新时间:2021.9.2# -*- coding = utf-8 -*-# @Time : 14:42# @Author : 李新宇# @File : demo2.py# @Software : PyCharm'''#这是我的第一个python程序print("hello,world") #这是单行注释print("python")print("标准化输出字符串")a = 10print("这位是变量 ",a)#格式化输出age = 18print原创 2021-09-02 21:50:50 · 69 阅读 · 0 评论