pip更新失败,超时的解决方法
摘要:pip源的更改: pip的默认源在国外,pip install some_packages特别慢,经常会超时,导致安装失败; pip 更换为国内的镜像 一:使用方法: ①临时使用: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
阅读全文
posted @
2020-03-30 18:10
共感的艺术
阅读(1868)
推荐(0) 编辑
协程提取上海人民法院网站信息
摘要:协程提取上海人民法院网站信息: import gevent import gevent.monkey import selenium import selenium.webdriver import urllib.request from bs4 import BeautifulSoup impor
阅读全文
posted @
2020-03-13 03:20
共感的艺术
阅读(145)
推荐(0) 编辑
协程原理 | 协程案例切换 | 协程开发 | 协程网络下载
摘要:协程原理: def go(): print(1) yield(1) #生成器 print(11) yield(11) print(111) yield (111) my=go() #分段执行 print(type(my)) print(next(my)) 协程案例切换: import greenle
阅读全文
posted @
2020-03-13 03:18
共感的艺术
阅读(155)
推荐(0) 编辑
str转json | python的list、dict转json string | json读写 | jsonpath操作
摘要:str转json: import json #json字符串,js类型跟字符串有关系,平时最多是字典 mydict='{"name":"yincheng","QQ":["758564524","1234"]}' #dict mydict='[1,2,3,4,5,6]' #list print( js
阅读全文
posted @
2020-03-13 03:13
共感的艺术
阅读(2974)
推荐(0) 编辑
pyquery遍历与获取数据、pyquery网站
摘要:pyquery遍历与获取数据: #coding:utf-8 import pyquery doc=pyquery.PyQuery(filename="index.html") print(doc(".item-0.active")) #一个节点; #.表示class名称; #.active .替换了
阅读全文
posted @
2020-03-13 03:08
共感的艺术
阅读(676)
推荐(0) 编辑
pyquery的简单用途、初始化方式、css选择
摘要:pyquery的简单用途: import pyquery html=""" <html> <title>这是标题</title> <body> <p id="hi">Hello</p> <ul> <li>list1</li> <li>list2</li> </ul> </body> </html>
阅读全文
posted @
2020-03-13 03:06
共感的艺术
阅读(268)
推荐(0) 编辑
requests的cookie操作,cookie自动化
摘要:requests的cookie操作,cookie自动化 一、requests的cookie操作: import requests user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' #模拟一个计算机 headers={'User
阅读全文
posted @
2020-03-13 03:03
共感的艺术
阅读(701)
推荐(0) 编辑
requests文件_json、异常、代理、其它功能
摘要:requests文件_json: #coding:utf-8 import requests import json #url="http://httpbin.org/post" #data textfile newurl="http://pythonscraping.com/pages/proce
阅读全文
posted @
2020-03-13 03:00
共感的艺术
阅读(149)
推荐(0) 编辑
selenium登录csdn,urllib抓取数据
摘要:selenium登录csdn,urllib抓取数据: import selenium import requests import selenium.webdriver import selenium.webdriver.common.keys import time #需要手动滑动验证码 driv
阅读全文
posted @
2020-03-13 02:53
共感的艺术
阅读(237)
推荐(0) 编辑
selenium登录12306,requests抓取数据
摘要:selenium登录12306,requests抓取数据: import selenium import selenium.webdriver import selenium.webdriver.common.keys from selenium.webdriver.common.action_ch
阅读全文
posted @
2020-03-13 02:52
共感的艺术
阅读(314)
推荐(0) 编辑
selenium登录淘宝,requests抓取购物车
摘要:selenium登录淘宝,requests抓取购物车: import selenium import selenium.webdriver import selenium.webdriver.common.keys import requests import lxml import lxml.et
阅读全文
posted @
2020-03-13 02:50
共感的艺术
阅读(726)
推荐(0) 编辑
selenium登录京东,requests抓取购物车
摘要:selenium登录京东,requests抓取购物车: import selenium import selenium.webdriver import selenium.webdriver.common.keys import requests import lxml import lxml.et
阅读全文
posted @
2020-03-13 02:49
共感的艺术
阅读(592)
推荐(0) 编辑
requests抓取json判断IP所在地
摘要:requests抓取json判断IP所在地: import requests import requests.auth #auth 代表登录 req=requests.get("https://api.ip2country.info/ip?113.88.65.106",verify=False) #
阅读全文
posted @
2020-03-13 02:48
共感的艺术
阅读(221)
推荐(0) 编辑
requests登录路由器
摘要:requests登录路由器: import requests import requests.auth #auth 代表登录 #路由器在登录的时候会在网页 弹出一个框 让输入用户名和密码 #登录路由器 auth=requests.auth.HTTPBasicAuth("ryan","password
阅读全文
posted @
2020-03-13 02:47
共感的艺术
阅读(347)
推荐(0) 编辑
requests的session的操作,登录一次之后,保持登录状态
摘要:requests的session的操作,可实现登录一次之后,保持记录,访问其它页面时处于登录状态: import requests import time headers={"User-Agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit
阅读全文
posted @
2020-03-12 11:04
共感的艺术
阅读(2427)
推荐(0) 编辑
requests的get、post、ssl、cookie操作
摘要:一、requests的get操作: import requests data={"wd":"关晓彤"} headers={"User-Agent" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko
阅读全文
posted @
2020-03-12 11:02
共感的艺术
阅读(489)
推荐(0) 编辑
requests的基本信息
摘要:requests的基本信息: import requests r=requests.get("http://www.baidu.com") r.encoding="utf-8" #utf-8解码 print(r.url) #链接 print(r.status_code) #响应码 print(r.h
阅读全文
posted @
2020-03-12 10:57
共感的艺术
阅读(126)
推荐(0) 编辑
selenium自定义隐藏浏览器,目前处于失败状态,仅供参考
摘要:selenium自定义隐藏浏览器,目前处于失败状态,仅供参考: #coding:utf-8 import pyvirtualdisplay #导入隐藏浏览器的包 import selenium.webdriver import time #visible=1代表可以显示#; size=(1024,7
阅读全文
posted @
2020-03-12 10:53
共感的艺术
阅读(683)
推荐(0) 编辑
selenium实现csdn登录,目前已失效,仅供参考操作
摘要:selenium实现csdn登录,目前已失效,仅供参考操作: import urllib import urllib.request import http.cookiejar from urllib import parse #fiddler抓取登录的POST,用户名和密码为明文,后面的参数key
阅读全文
posted @
2020-03-12 10:52
共感的艺术
阅读(287)
推荐(0) 编辑
selenium的down操作
摘要:selenium的down操作,实现文件下载: import selenium import selenium.webdriver import time import os options=selenium.webdriver.ChromeOptions() #download.default_d
阅读全文
posted @
2020-03-12 10:50
共感的艺术
阅读(267)
推荐(0) 编辑
selenium视频点击播放,videojs
摘要:selenium视频点击播放,videojs: import selenium import selenium.webdriver import time #网页很多网页源码不在页面上显示,一些通过js或者json方式来传输,可以通过看str等超链接,来分析源码 url="http://videoj
阅读全文
posted @
2020-03-12 10:49
共感的艺术
阅读(1839)
推荐(0) 编辑
selenium检索代理,代理验证,保存本地
摘要:selenium检索代理: import selenium import selenium.webdriver url="http://www.kuaidaili.com/free/inha/4/" driver=selenium.webdriver.Chrome() driver.get(url)
阅读全文
posted @
2020-03-12 10:47
共感的艺术
阅读(398)
推荐(0) 编辑
selenium提取网页文本
摘要:selenium提取网页文本: import selenium import selenium.webdriver url="https://www.51shucheng.net/kehuan/santi/santi1/174.html" driver=selenium.webdriver.Chro
阅读全文
posted @
2020-03-12 10:45
共感的艺术
阅读(2006)
推荐(0) 编辑
selenium的cookie操作
摘要:selenium的cookie操作: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver=webdriver.Chrome() #配置参数 driver.g
阅读全文
posted @
2020-03-12 10:43
共感的艺术
阅读(190)
推荐(0) 编辑
selenium调用js
摘要:selenium调用js: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver=webdriver.Chrome() #配置参数 driver.get("h
阅读全文
posted @
2020-03-12 10:42
共感的艺术
阅读(361)
推荐(0) 编辑
selenium网页操作_选择
摘要:selenium网页操作_选择: #coding:utf-8 from selenium import webdriver import time from selenium.webdriver.common.action_chains import ActionChains #鼠标 from se
阅读全文
posted @
2020-03-12 10:41
共感的艺术
阅读(301)
推荐(0) 编辑
selenium网页提示框_默认确定
摘要:selenium网页提示框_默认确定: #coding:utf-8 from selenium import webdriver import time from selenium.webdriver.common.action_chains import ActionChains driver=w
阅读全文
posted @
2020-03-12 10:40
共感的艺术
阅读(265)
推荐(0) 编辑
selenium多个浏览器窗口_切换
摘要:selenium多个浏览器窗口_切换: from selenium import webdriver import time driver=webdriver.Chrome() #配置参数 driver.get("http://www.baidu.com") time.sleep(3) #<a hr
阅读全文
posted @
2020-03-12 10:39
共感的艺术
阅读(1379)
推荐(0) 编辑
selenium页面搜索批量抓取
摘要:selenium页面搜索批量抓取: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait #
阅读全文
posted @
2020-03-12 10:38
共感的艺术
阅读(590)
推荐(0) 编辑
selenium解决页面加载实战
摘要:selenium解决页面加载实战: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait #
阅读全文
posted @
2020-03-12 10:37
共感的艺术
阅读(502)
推荐(0) 编辑
selenium页面加载慢的问题
摘要:selenium页面加载慢的问题: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait #
阅读全文
posted @
2020-03-12 10:36
共感的艺术
阅读(2232)
推荐(0) 编辑
selenium的键盘keybord操作
摘要:selenium的键盘keybord操作: from selenium import webdriver from selenium.webdriver.common.keys import Keys import time driver=webdriver.Chrome() #配置参数 drive
阅读全文
posted @
2020-03-12 10:35
共感的艺术
阅读(314)
推荐(0) 编辑
selenium的鼠标mouse操作
摘要:selenium的鼠标mouse操作: from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains import time driver=webdriver.Chrom
阅读全文
posted @
2020-03-12 10:34
共感的艺术
阅读(564)
推荐(0) 编辑
selenium登录手机淘宝
摘要:selenium登录手机淘宝: from selenium import webdriver import time #测试可以实现模拟登录,登录验证码未解决 ,但是可以在下方设置time.sleep(),时间长一点手动操作验证码,实现成功登录 #打开谷歌后,切换到手机模式,会看到手机的页面,实质上
阅读全文
posted @
2020-03-12 10:32
共感的艺术
阅读(1719)
推荐(0) 编辑
selenium手机模拟登录
摘要:selenium手机模拟登录: from selenium import webdriver import time #测试可以实现模拟登录,登录验证码未解决 ,但是可以在下方设置time.sleep(),时间长一点手动操作验证码,实现成功登录 #打开谷歌后,切换到手机模式,会看到手机的页面,实质上
阅读全文
posted @
2020-03-12 10:31
共感的艺术
阅读(773)
推荐(0) 编辑
selenium手机百度搜索
摘要:selenium手机百度搜索: from selenium import webdriver import time #打开谷歌后,切换到手机模式,会看到手机的页面,实质上,手机上的APP就是一个手机版浏览器 #设置 mobilesetting={"deviceName":"iPhone 6 Plu
阅读全文
posted @
2020-03-12 10:30
共感的艺术
阅读(462)
推荐(0) 编辑
selenium模拟手机浏览器
摘要:selenium模拟手机浏览器: from selenium import webdriver import time #打开谷歌后,切换到手机模式,会看到手机的页面,实质上,手机上的APP就是一个手机版浏览器 #设置 mobilesetting={"deviceName":"iPhone 6 Pl
阅读全文
posted @
2020-03-12 10:29
共感的艺术
阅读(1813)
推荐(0) 编辑
selenium模拟登录赶集网,手动解决验证码问题
摘要:selenium模拟登录赶集网,未解决验证码问题,但是可以在下方设置time.sleep(),时间长一点手动操作验证码,实现成功登录: import selenium import selenium.webdriver import selenium.webdriver.common.keys im
阅读全文
posted @
2020-03-11 11:14
共感的艺术
阅读(495)
推荐(0) 编辑
selenium模拟登录京东,手动解决验证码问题,抓取购物车价格
摘要:selenium模拟登录京东,未解决验证码问题,但是可以在下方设置time.sleep(),时间长一点手动操作验证码,实现成功登录,并抓取了购物车价格: import selenium import selenium.webdriver import selenium.webdriver.commo
阅读全文
posted @
2020-03-11 11:13
共感的艺术
阅读(693)
推荐(0) 编辑
selenium模拟登录QQ空间,手动解决验证码问题
摘要:selenium模拟登录QQ空间,未解决验证码问题,但是可以在下方设置time.sleep(),时间长一点手动操作验证码,实现成功登录: #coding:utf-8 import selenium import selenium.webdriver import time #QQ空间 现在登录需要验
阅读全文
posted @
2020-03-11 11:12
共感的艺术
阅读(518)
推荐(0) 编辑
selenium无界面浏览器,访问百度搜索为例
摘要:selenium无界面浏览器,访问百度搜索,输入关键词,打印快照: import selenium import selenium.webdriver import selenium.webdriver.common.keys import time driver = selenium.webdri
阅读全文
posted @
2020-03-11 11:10
共感的艺术
阅读(150)
推荐(0) 编辑
selenium无界面浏览器
摘要:selenium无界面浏览器,需要用到PhantomJS: import selenium import selenium.webdriver import time #phantomjs.exe 路径需添加系统环境变量 executable_path为环境变量地址 driver=selenium.
阅读全文
posted @
2020-03-11 11:09
共感的艺术
阅读(606)
推荐(0) 编辑
selenium验证码的解决办法
摘要:转载自https://www.cnblogs.com/wuzhiyi/p/6020967.html selenium验证码的解决办法: 在做web自动化登录时,每当遇到验证码有几种解决方式: 1,设置万能验证码 2,通过pytesser破解图片 3,通过代码控制等待手动输入验证(附代码) 下面就是第
阅读全文
posted @
2020-03-11 11:07
共感的艺术
阅读(520)
推荐(0) 编辑
selenium简单识别验证码
摘要:selenium简单识别验证码,识别验证码图片,不太精准,原理上是这样: import subprocess #验证png图片不报错,可以识别图片为文字,但是不精准,jpg也可以识别,但是会报错,也会生出txt文档 #第一个是安装的Tesseract-OCR的路径,第二个是验证码的图片的路径 p=s
阅读全文
posted @
2020-03-11 10:56
共感的艺术
阅读(224)
推荐(0) 编辑
selenium暴力破解密码,正确密码终止程序
摘要:selenium暴力破解密码,实现正确密码终止程序,打印显示正确密码: #coding:utf-8 import selenium import selenium.webdriver import time #测试暴力破解 登录地址 用户名 密码需要填写 def loginoa(username,p
阅读全文
posted @
2020-03-11 10:55
共感的艺术
阅读(758)
推荐(0) 编辑
selenium暴力破解密码,测试帝国后台
摘要:selenium暴力破解密码,实测帝国后台,在破解过程中,密码库丰富的话,在出现正确密码的时候,会终止程序,并且打印显示正确密码,但是帝国后台有限制用户名密码输入登录次数,可通过定时time.sleep(),找到临界点进行破解: #coding:utf-8 import selenium impor
阅读全文
posted @
2020-03-11 10:53
共感的艺术
阅读(541)
推荐(0) 编辑
selenium模拟web登录,测试帝国后台成功登录
摘要:selenium模拟web登录,测试过程中,已实现帝国后台的成功登录: #coding:utf-8 import selenium import selenium.webdriver import time #测试网站,帝国 后台已成功登录 def loginoa(username,password
阅读全文
posted @
2020-03-11 10:49
共感的艺术
阅读(430)
推荐(0) 编辑
selenium的web浏览器
摘要:selenium的web浏览器:把相应的driver下载好后,需要放到python安装的目录下,不放上的话需要配置环境变量,并在浏览器括号内填写executable_path="driver安装路径"。放在python路径下不用填写 import selenium import selenium.w
阅读全文
posted @
2020-03-11 10:47
共感的艺术
阅读(138)
推荐(0) 编辑
运用python3中的urllib爬取贴吧的图片
摘要:运用python3中的urllib爬取贴吧的图片: import urllib import urllib.request import lxml import lxml.etree import re from urllib import parse #抓取贴吧页面数量信息 def gettieb
阅读全文
posted @
2020-03-11 10:31
共感的艺术
阅读(444)
推荐(0) 编辑
selenium实现alibaba下一页
摘要:运用selenium实现alibaba工作职位页面的下一页: import selenium import selenium.webdriver import selenium.webdriver.common.keys import time driver = selenium.webdriver
阅读全文
posted @
2020-03-10 10:33
共感的艺术
阅读(188)
推荐(0) 编辑
selenium模拟登录csdn
摘要:selenium模拟登录csdn,可以输入用户名和密码,但是验证码还没有解决: import selenium import selenium.webdriver import selenium.webdriver.common.keys import time driver = selenium.
阅读全文
posted @
2020-03-10 10:29
共感的艺术
阅读(142)
推荐(0) 编辑
selenium 进行百度搜索页面的关键词提交,以及RETURN确定
摘要:运用selenium 进行百度搜索页面的关键词提交,以及enter确定到下一个页面: import selenium import selenium.webdriver import selenium.webdriver.common.keys import time driver = seleni
阅读全文
posted @
2020-03-10 10:26
共感的艺术
阅读(421)
推荐(0) 编辑
lmxl的xpath提取脚本之间的title以及url
摘要:运用lmxl的xpath提取脚本之间的title以及url: import urllib.request import lxml import lxml.etree import re def makeurllist(url): headers={"User-Agent":"Mozilla/5.0
阅读全文
posted @
2020-03-10 10:21
共感的艺术
阅读(783)
推荐(0) 编辑
lxml中的xpath股票信息提取
摘要:lxml中的xpath股票信息提取: import urllib.request import lxml import lxml.etree import re def download(url): headers={"User-Agent":"Mozilla/5.0 (compatible; MS
阅读全文
posted @
2020-03-10 10:19
共感的艺术
阅读(209)
推荐(0) 编辑
lxml中的xpat详细使用介绍
摘要:lxml中的xpat详细使用介绍: import lxml import lxml.etree html=lxml.etree.parse("index.html") print(type(html)) res=html.xpath("//li") #res是一个列表,包含所有元素 print(le
阅读全文
posted @
2020-03-10 10:17
共感的艺术
阅读(411)
推荐(0) 编辑
lxml中的Xpath的使用
摘要:lxml中的Xpath的使用: #coding:utf-8 import lxml import lxml.etree text=""" <div> <ul> <li class="item-0"><a href="link1.html">first item</a></li> <li class=
阅读全文
posted @
2020-03-10 10:16
共感的艺术
阅读(233)
推荐(0) 编辑
python3中运用urllib抓取贴吧的邮箱以及QQ
摘要:python3中运用urllib抓取贴吧的邮箱以及QQ: import urllib import urllib.request import re from urllib import parse #抓取贴吧页面数量信息 def gettiebalistnumbers(name): #计算搜索的关
阅读全文
posted @
2020-03-10 10:14
共感的艺术
阅读(419)
推荐(0) 编辑
人形词云,根据图片黑白形状绘制词云
摘要:人形词云,根据图片黑白形状,绘制词云: #coding:utf-8 """ Masked wordcloud Using a mask you can generate wordclouds in arbitrary shapes. """ from os import path from PIL
阅读全文
posted @
2020-03-09 11:24
共感的艺术
阅读(1726)
推荐(0) 编辑
汉化的simple词云
摘要:汉化的simple词云: #coding:utf-8 """ Minimal Example Generating a square wordcloud from the US constitution using default arguments. """ from os import path
阅读全文
posted @
2020-03-09 11:22
共感的艺术
阅读(165)
推荐(0) 编辑
对于数据的平均值处理
摘要:对于数据的平均值处理: def checkstr(mystr): try: num=eval(mystr) return True except: return False file=r"D:\python爬虫视频\爬虫代码\处理爬虫数据排序\nasa.txt" readfile=open(file
阅读全文
posted @
2020-03-09 11:18
共感的艺术
阅读(552)
推荐(0) 编辑
文字替换成函数返回数字进行排序
摘要:文字替换成函数返回数字进行排序: def xueli(study): if study == "博士后": return 10 elif study == "博士": return 9 elif study == "硕士": return 8 elif study == "本科": return 7
阅读全文
posted @
2020-03-09 11:17
共感的艺术
阅读(260)
推荐(0) 编辑
校验
摘要:校验 mystr=input("输入数据") try: num=eval(mystr) print(num) print("ok") except: print("失败")
阅读全文
posted @
2020-03-09 11:16
共感的艺术
阅读(131)
推荐(0) 编辑
Python:使用lambda对列表(list)和字典(dict)排序
摘要:转自风雪飘殇博客 自己验证实现并整理,对列表和字典排序时lambda的用法。 函数介绍 sorted() sorted函数: sorted(iterable[,key][,reverse]) 函数接收三个参数:排序的变量、排序的规则、升降序选择 lambda lambda 匿名函数一般形式 def
阅读全文
posted @
2020-03-09 11:14
共感的艺术
阅读(995)
推荐(0) 编辑
python中的数据排序
摘要:python中对于抓取的数据进行排序: def checkstr(mystr): try: num=eval(mystr) return True except: return False filepath=r'D:\python爬虫视频\爬虫代码\处理爬虫数据排序\nasa.txt' readfi
阅读全文
posted @
2020-03-09 11:09
共感的艺术
阅读(391)
推荐(0) 编辑
运用selenium、urllib抓取51job上的python任职要求,保存为txt文本
摘要:运用selenium、urllib抓取51job上的python岗位任职要求,形成一个txt文本: import selenium #测试框架 import selenium.webdriver #模拟浏览器 import re import urllib import urllib.request
阅读全文
posted @
2020-03-09 11:05
共感的艺术
阅读(315)
推荐(0) 编辑
51job词云
摘要:爬取的51job上的python岗位任职要求,形成了词云: # coding:utf-8 import jieba #分词 import matplotlib.pyplot as plt #数据可视化 import wordcloud from wordcloud import WordCloud,
阅读全文
posted @
2020-03-09 10:58
共感的艺术
阅读(220)
推荐(0) 编辑
python3中的词云,自定义生成词云
摘要:python3中的词云,通过添加文本,以及图片和字体路径,自定义生成词云: # coding:utf-8 import jieba #分词 import matplotlib.pyplot as plt #数据可视化 import wordcloud from wordcloud import Wo
阅读全文
posted @
2020-03-09 10:56
共感的艺术
阅读(1349)
推荐(0) 编辑
python3中的词云,运用jieba进行分词
摘要:python3中的词云,用到jieba来进行分词: import jieba mystr="我今天早上遇到一个美女要电话,美女说你有病,我回答正是因为你我才害了相思病" """ sg_list=jieba.cut(mystr,cut_all=True) #普通切割 print("/".join(sg
阅读全文
posted @
2020-03-09 10:52
共感的艺术
阅读(316)
推荐(0) 编辑
python3中的matplotlib绘图,绘制51job的python职位树形图
摘要:python3中的matplotlib绘图,绘制51job上抓取的python各职位的树形图: import selenium #测试框架 import selenium.webdriver #模拟浏览器 import re import matplotlib import matplotlib.p
阅读全文
posted @
2020-03-09 10:50
共感的艺术
阅读(370)
推荐(0) 编辑
python3中的matplotlib绘图,plt.bar绘制树形图
摘要:python3中的绘图,用到 matplotlib,没有安装可以 pip install matplotlib 进行安装: import matplotlib import matplotlib.pyplot as plt #数据可视化 matplotlib.rcParams["font.sans-
阅读全文
posted @
2020-03-09 10:47
共感的艺术
阅读(1291)
推荐(0) 编辑
urllib登录的cookie复制到headers,模拟登录人人网
摘要:python3中的urllib库进行模拟登录人人网,这里主要是登录人人网成功后,把登录后的cookie复制到headers里,进行模拟登陆,然后保存到本地html。 from urllib import request url ="http://www.renren.com/967952300/pr
阅读全文
posted @
2020-03-08 11:10
共感的艺术
阅读(225)
推荐(0) 编辑
urllib中的保存cookie使用,运用cookiejar来模拟登录人人网
摘要:python3中urllib库进行模拟登录,这里主要是保存cookie,以访问人人网为例: import http.cookiejar from urllib import parse #创建一个对象,存储cookie cookie = http.cookiejar.CookieJar() #创建一
阅读全文
posted @
2020-03-08 11:06
共感的艺术
阅读(307)
推荐(0) 编辑
urllib中的cookie使用,四种方法
摘要:python3中的urllib库对于cookie使用,下面整理了四种方法: 一、readcookie import urllib.request import http.cookiejar URL_ROOT = "http://www.baidu.com" cookie = http.cookiej
阅读全文
posted @
2020-03-08 11:03
共感的艺术
阅读(604)
推荐(0) 编辑
urllib中的https使用,导入ssl模块
摘要:之前访问百度的时候,代码总会出现请求超时,不知道什么原因,学了的https后,解决了这个问题: import urllib import urllib.request import ssl #导入Python SSL处理模块 #如果网站的SSL证书是经过CA认证,就需要单独处理SSL证书,让程序忽略
阅读全文
posted @
2020-03-08 10:51
共感的艺术
阅读(1359)
推荐(0) 编辑
urllib判断重定向
摘要:python3中的urllib库里的重定向判断,响应码出现302为重定向,以访问百度为例: from urllib import request class NoRedirHandler(request.HTTPRedirectHandler): def http_error_302(self, r
阅读全文
posted @
2020-03-08 10:47
共感的艺术
阅读(367)
推荐(0) 编辑
urllib中的down,下载百度图片为例
摘要:python3中的urllib库下载功能,这里主要用到了urlretrieve,以下载百度图片为例,前面为url地址,后面为文件名。 import urllib.request urllib.request.urlretrieve("https://timgsa.baidu.com/timg?ima
阅读全文
posted @
2020-03-08 10:44
共感的艺术
阅读(217)
推荐(0) 编辑
urllib中的本地代理设置
摘要:python3中的urllib设置本地代理: import urllib.request import urllib.parse # 113.79.75.104:9797 # 创建handler handler = urllib.request.ProxyHandler({'http': '114.
阅读全文
posted @
2020-03-08 10:40
共感的艺术
阅读(306)
推荐(0) 编辑
requests访问手机百度
摘要:python3中的requests访问百度的Android手机浏览器: import requests def downloadasAndroid(url): headers={"User-Agent":"Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BL
阅读全文
posted @
2020-03-08 10:38
共感的艺术
阅读(1363)
推荐(0) 编辑
urllib|requests爬取网页Ajax,以豆瓣电影为例
摘要:python3中的urllib库和requests库的使用,这里主要介绍下什么是Ajax,以及对于网页Ajax的爬取,以豆瓣电影为例,分别用urllib库和requests库进行抓取。 一、什么是Ajax? “Ajax 即“Asynchronous Javascript And XML”(异步 Ja
阅读全文
posted @
2020-03-08 10:29
共感的艺术
阅读(756)
推荐(0) 编辑
urllib中的post请求的使用
摘要:python3中的urllib的post请求的使用,以访问拉钩为例,虽然出现操作太频繁的运行,但是也可以熟悉下相关post请求的操作。 import urllib.request #拉钩fiddle抓包POST https://www.lagou.com/jobs/positionAjax.json
阅读全文
posted @
2020-03-08 10:20
共感的艺术
阅读(985)
推荐(0) 编辑
urllib中的get使用,以访问智联为例
摘要:python3中的urllib库的get使用,以访问智联为例,虽然现在智联需要验证码了,但是也不妨我们做个练习,巩固下get的使用。 #如果一个网站屏蔽了你 #解决办法: (1)模拟浏览器 ; (2)伪装浏览器 import urllib import urllib.request from url
阅读全文
posted @
2020-03-08 10:15
共感的艺术
阅读(219)
推荐(0) 编辑
urllib中的get请求
摘要:下面为python3中的urllib库对于get请求的使用方法,接口的地方需要拼接地址,以访问百度为例,附上代码: import urllib from urllib import request from urllib import parse #导入编码 解码 headers={"User-Ag
阅读全文
posted @
2020-03-08 10:11
共感的艺术
阅读(638)
推荐(0) 编辑
urllib中的网页的编码(urlencode)、解码(unquote)
摘要:python3中的urllib网页的编码(urlencode)、解码(unquote),以访问百度为例,在接口输入字符的时候为中文,但是计算机需要编码才能识别。 from urllib import request from urllib import parse #导入编码 解码包 #百度url
阅读全文
posted @
2020-03-08 10:03
共感的艺术
阅读(984)
推荐(0) 编辑
urllib中的User-Agent使用
摘要:下面主要是python3中的urllib库中的相关知识及User-Agent设置: 一、什么是User-Agent? User-Agent是Http协议中的一部分,属于头域的组成部分,User Agent也简称UA。用较为普通的一点来说,是一种向访问网站提供你所使用的浏览器类型、操作系统及版本、CP
阅读全文
posted @
2020-03-08 09:57
共感的艺术
阅读(1539)
推荐(0) 编辑
urllib中的response、error的使用介绍
摘要:总结下昨天学习的代码知识,主要是python3的urllib的基础知识。 下面为urllib库中的response、error的使用介绍: import urllib.request from urllib import error #error 异常 error下有2个异常 except erro
阅读全文
posted @
2020-03-08 09:46
共感的艺术
阅读(900)
推荐(0) 编辑
selenium安装使用,selenium模拟浏览器抓取51job上的 python职位和工资
摘要:今天整理下昨天学习的代码,主要是学习了selenium模拟浏览器登录来抓取51job,下面先分享下使用selenium需要注意的点: 1、在使用selenium的时候,可以通过pip install selenium来进行安装; 2、安装完selenium后,需要去网上下载相应的chromedriv
阅读全文
posted @
2020-03-07 10:26
共感的艺术
阅读(435)
推荐(0) 编辑