Python爬虫
.Passion
欢迎来看我的博客 ,原博客地址: https://www.cnblogs.com/lyr-2000/
现决定重新启用博客园的博客,一部分比较浅的笔记将写到这个博客上
欢迎打扰,另外,个人博客网站也搭建成功,欢迎打扰:
https://lyr-2000.github.io/
展开
-
img 获取二次元图片地址
python 获取二次元图片地址使用 python 调用图片地址接口,然后将地址之间粘贴到 clipboard 。import requests#importing the moduleimport pyperclipres = requests.get('https://api.mtyqx.cn/api/random.php?return=json') imgurl = res.json().get('imgurl')print(imgurl)# copies all the da原创 2022-05-17 23:17:06 · 339 阅读 · 0 评论 -
python 爬虫,爬取京东商品信息
import requestsfrom bs4 import BeautifulSoupimport numpy as npimport pandas as pdheaders_index = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", 'HOST': 'www原创 2020-09-28 15:59:37 · 1423 阅读 · 1 评论 -
#python爬虫实战,爬取学校排名
import requestsfrom bs4 import BeautifulSoupimport bs4target = "http://www.zuihaodaxue.cn/zuihaodaxuepaiming2019.html"def start_page(url,callback): resp = requests.get(url) callback(resp.content)def printHtml(text): soup = BeautifulSou.原创 2020-09-15 22:06:08 · 368 阅读 · 0 评论 -
#回归基础 # request 库的概念
原创 2020-09-14 23:47:48 · 69 阅读 · 0 评论 -
#终篇# 使用 pyspider 爬自己的博客
#!/usr/bin/env python# -*- encoding: utf-8 -*-# Created on 2020-08-26 20:25:43# Project: pa_baidufrom pyspider.libs.base_handler import *class Handler(BaseHandler): crawl_config = { 'headers':{ 'User-Agent':"GoogleBot", .原创 2020-09-12 22:00:06 · 70 阅读 · 0 评论 -
pandas数据整理总结
原创 2020-05-20 01:22:57 · 178 阅读 · 0 评论 -
Pandas的基本数据结构
Pandas提供3种基本数据结构1.Series: 带标签的一维数组2.DataFrame: 带标签的二维数组(即表格)3.Panel: 带标签的 3维数组pd.versionOut[10]: ‘0.20.1’s2=Series([10,20,30],index=[‘a’,‘b’,‘c’])s2创建一个以为数组,可以用 标签 或者 需要下标访问这个数组s1.head()Out[30]:0 101 202 30dtype: int64s9.head()Out原创 2020-05-15 13:28:16 · 598 阅读 · 0 评论 -
numpy的使用
使用 %timeit 魔数 命令 计算耗时np.mean(lst) -> 计算 lst 的平均数np.average(x,weight=w) 安装 权重计算平均值numpy 两个 数组直接 乘 就是 矩阵乘法了np.sum(x*w)/np.sum(w) 按照 权重 求平均值ar = np.arange(6) 求数组的维度ar.ndim —> 数组的维度ar.size —> 数组的数据个数ar.shape --> (行,列)ar.itemsize --.原创 2020-05-13 11:16:08 · 127 阅读 · 0 评论 -
python 统计字典的个数
统计 字典的个数di = { "a":20, "b":88, "c":99, "d":9}from collections import Countercounts = Counter(di)for i in counts: print(i,counts[i])print(counts.most_common(3))...原创 2020-05-08 12:19:41 · 12217 阅读 · 0 评论 -
python 的常用问卷操作命令
os.getcwd() 返回问卷路径os.system(‘notepad.exe’) 打开记事本os.startfile(‘1.mp4’) 启动一个视频文件os.path 是个标准库,提供了一些常用的判断和路径 切分的功能...原创 2020-05-08 11:56:52 · 164 阅读 · 0 评论 -
python基本语法
1.序列:可以通过下标偏移量来访问一个或多个成员:有 字符串,列表,元组3 种类型序列基本操作:1.成员关系操作符: in , not in2. 连接关系操作符: + ( 序列+ 序列)3.重复操作符: * (序列 * 整数)3. 切片操作符 ( [ : ] ) 序列[0: 整数]lambda表达式语法lambda x: x<= c, array例子:l...原创 2020-01-05 15:11:33 · 102 阅读 · 0 评论 -
python 爬虫ip代理池
其他文章转载 2020-02-17 13:47:15 · 219 阅读 · 0 评论 -
beautifulsoup的简单使用
import requestsfrom bs4 import BeautifulSoupheaders = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "A...原创 2020-02-17 12:16:29 · 115 阅读 · 0 评论 -
多线程爬虫爬小说
import threadingurl = "https://xx.com/11/11947/"headers = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",...原创 2020-02-12 00:45:34 · 335 阅读 · 0 评论 -
代理ip
代理ip转载 2020-02-09 20:47:14 · 93 阅读 · 0 评论 -
爬取妹子图系列3
import requestsfrom bs4 import BeautifulSoupimport shutilheaders = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0', 'Referer': 'http://www.mzit...原创 2020-01-06 21:34:42 · 248 阅读 · 0 评论 -
requests库简单抓取链接
import requestsheaders = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "Accept-Encoding": "gzip, defla...原创 2020-01-06 20:05:54 · 442 阅读 · 0 评论 -
Python pip安装和升级
###首先 pip show pip查看当前 pip 的版本版本为 9.0.1因此要进行升级输入 ‘’python -m pip install --upgrade pip‘’即可升级可能有人发现自己的python不是内部命令报错我一开始也是这样,配置一下环境变量就好了我用的是 anaconda具体配置查看这里 看这里...原创 2019-06-29 01:32:40 · 354 阅读 · 0 评论 -
使用peewee创建一张表
orm是个好东西看代码from peewee import *# 利用 peewee自动生成表db = MySQLDatabase("spider", host="127.0.0.1", port=3306, user="root", password="422525")class Person(Model): name = CharField(max_length=10...原创 2019-10-03 01:47:50 · 1476 阅读 · 5 评论 -
python的正则表达式
python的正则表达式的使用如下图所示把a标签内的链接提取出来下面使用 urllib的request对豆瓣阅读的出版社信息进行打印import urllib.requestimport re# ctrl+alt+l reformat codedef main(): data = urllib.request.urlopen("https://read.douban...原创 2019-10-08 00:55:08 · 90 阅读 · 0 评论 -
爬取妹子图系列
爬取妹子图系列一‘’’import requestsimport oskv={'wd':'Python'}headers={'user-agent':'Mozilla/5.0'}url = "http://s9.rr.itc.cn/g/Q/aF/nuuy2Rz.jpg"root = 'f://meizitu//';path = root + url.split('/')[-1]...原创 2019-06-29 15:16:52 · 4810 阅读 · 0 评论