随笔分类 -  python爬虫

笔记
摘要:1、队列代码示例 import threading import time from queue import Queue ''' Queue是线程安全的队列 ''' def set_data(q): index = 0 while True: q.put(index) index += 1 tim 阅读全文
posted @ 2020-01-03 13:50 高文祥888888 阅读(310) 评论(0) 推荐(0)
摘要:1、多线程使用案例 import time import threading def coding(): for x in range(0,3): print("正在写代码......") print(threading.current_thread()) time.sleep(1) def dra 阅读全文
posted @ 2020-01-03 11:18 高文祥888888 阅读(175) 评论(0) 推荐(0)
摘要:1、记录python读写csv文件,直接上代码 import csv header = ["学号","姓名","年龄"] values = [ ("1","zhangsan","19"), ("2","lisi","20"), ("3","wangwu","22"), ] def read_csv_ 阅读全文
posted @ 2019-12-27 17:04 高文祥888888 阅读(204) 评论(0) 推荐(0)
摘要:1、古诗文网爬虫 import requests,re headers = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.39 阅读全文
posted @ 2019-12-24 14:24 高文祥888888 阅读(203) 评论(0) 推荐(0)
摘要:1、元字符介绍 "^" :^会匹配行或者字符串的起始位置,有时还会匹配整个文档的起始位置。 "$" :$会匹配行或字符串的结尾 "\b" :不会消耗任何字符只匹配一个位置,常用于匹配单词边界 如 我想从字符串中"This is Regex"匹配单独的单词 "is" 正则就要写成 "\bis\b" " 阅读全文
posted @ 2019-12-23 11:11 高文祥888888 阅读(203) 评论(0) 推荐(0)
摘要:一、中国天气网爬虫案例 #中国天气网爬虫 import requests from pyecharts.charts import Bar from bs4 import BeautifulSoup import copy import html5lib datas = [] data = { "c 阅读全文
posted @ 2019-12-11 20:34 高文祥888888 阅读(221) 评论(0) 推荐(0)
摘要:BeautifulSoupeautifulSoup使用笔记 from bs4 import BeautifulSoup ''' 1、find_all的使用: soup.find_all("ul");soup.find_all("ul",limit=2)[1];find_all("ul",class_ 阅读全文
posted @ 2019-12-09 19:28 高文祥888888 阅读(379) 评论(0) 推荐(0)
摘要:#电影天堂电影爬虫import requestsfrom lxml import etreeimport timeimport warningswarnings.filterwarnings('ignore')DOMAIN = "https://dytt8.net"HEADERS = { "Refe 阅读全文
posted @ 2019-12-05 18:50 高文祥888888 阅读(820) 评论(0) 推荐(0)
摘要:一、request.get()方法 import requestsheaders = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78. 阅读全文
posted @ 2019-12-02 13:38 高文祥888888 阅读(1880) 评论(0) 推荐(0)
摘要:1、urllib库 request模块: 1、发送请求:request.urlopen(url); 2、下载网页:request.urlretrieve(url); 3、代理模块:ProxyHandler 1、使用proxyHandler,传入代理构建一个handler handler = requ 阅读全文
posted @ 2019-11-29 11:33 高文祥888888 阅读(144) 评论(0) 推荐(0)