html滑动登录页面
很多同学在进行编程学习时缺乏系统学习的资料。本页面基于html滑动登录页面内容,从基础理论到综合实战,通过实用的知识类文章,标准的编程教程,丰富的视频课程,为您在html滑动登录页面相关知识领域提供全面立体的资料补充。同时还包含 h6、hack、hadoop 的知识内容,欢迎查阅!
html滑动登录页面相关知识
-
使用Python自动登录SSO爬取动态页面最近的项目在做一些数据方面的集成,五花八门的系统对应的接口更是千奇百怪,数据集成的过程总结成八个字就是:逢山开路,遇水架桥。恰好这两天碰到一个问题,我们要集成的WEB系统没有提供专门的数据集成接口,没有API可以调,数据库更是不让访问,万般无奈之下,我在想是否可以用python自动爬取页面。web页面有SSO,用的应该是开源的CAS框架,并且后面的页面全都是由动态JS、AJAX异步加载进去的,这显然不像普通的静态页面那样直接用Scrapy上去就是一顿干,要完美的模拟登陆动作并且还要爬取后面的动态内容,对页面结构和爬取内容的分析是必不可少的。工具Chrome页面分析工具非常简单,只需要最新版本的Chrome浏览器即可python3requests分析登录页面打开登录页面,按F12打开Chrome自带的分析工具,在Network选卡上可以看到当前浏览器显示页面和提交登录信息的详情,如下图某网站登录页面从截图上可以看到,当我们访问app/这个url的日志,因为我们还没有登录过,SSO会把我们自动重定向到登录页面,
-
Python2.7自动登录并获取cookies前言Python由于其第三方库扩展多、接口简洁、处理网页方便等原因被广泛应用于爬虫的编写。网络爬虫的第一步即是要能够实现代码的自动登录,登录后使用获得的cookies来访问页面。本文使用Python2.7.13+Requests来实现简单网页的登录(不含验证码)。获取需要提交的变量自动登录的基本原理是模拟人工填入账号密码,并向服务器进行提交,获取服务器的应答(以cookies的形式)。因此第一步我们需要知道在网页端登录时,浏览器向服务器提交的账号与密码的变量分别是什么?这里以Google Chrome为例演示如何查看提交的账号与密码的变量名(其他浏览器类似):打开需要登录的网址,并按F12,之后选择“Network”标签(勾选“preserve log”)如图:之后填入账号、密码并进行登录,登录成功后在下面的页面Name中点击第一个,会在右边弹出下面的窗口,滑动到最下面可以看到Form Data,即是浏览器向服务器POST提交的数据。自动登录就是使用程序向服务器提交这些数据:其中userName即是输入的账
-
【移动端】js禁止页面滑动与允许滑动禁止页面滑动通常静止滑动方案:(阻止滑动事件)window.ontouchmove=function(e){ e.preventDefault && e.preventDefault(); e.returnValue=false; e.stopPropagation && e.stopPropagation(); return false; };有部分机型不支持以上静止滑动方案,可使用:(点击后页面浮动到指定位置不动 将body的position设置为fixed)$("#btn").click(function(){ var top=$(window).scroll
-
多加一行代码,突破淘宝模拟登录滑块上次的文章有“怂恿”大家伙去突破淘宝的登录反爬,不知道有没有试了的。反正我是试了,也找到了三种方法。在这里分享一下 账号密码登录(有滑块) 微博第三方账号登录(无滑块) 扫码登录 上面都是使用 Selenium 进行模拟登录的,这样就可以不用手动添加各种Cookie或者Session,少了很多工作。 # 淘宝账号登录 一般直接使用Selenium自动控制登录,都会无法通过滑块验证。所以解决的策略就是让这些网站识别不出来你是用了Selenium,因此需要将模拟浏览器设置为开发者模式,这样就可以防止被
html滑动登录页面相关课程
-
PHP第三方登录—QQ登录 想使用最简单的方法为我们的Web应用获取新用户,你绝对不应该错过。使用QQ互联官方提供的SDK快速接入QQ互联开放平台,迅速获取海量用户。
讲师:壞大叔bbUncle 中级 47049人正在学习
-
PHP第三方登录—微博登录 想使用最简单的方法为我们的Web应用获取新用户,你绝对不应该错过本门课程。本课程带领大家掌握使用微博开放平台提供的SDK快速接入微博开放平台,迅速获取海量用户。
讲师:壞大叔bbUncle 中级 23211人正在学习
-
PHP第三方登录—OAuth2.0协议 本课程主要介绍第三方登录相关协议—OAuth2.0协议。主要介绍了OAuth的使用场景和实现原理,并结合实际讲解了OAuth2.0协议使用的注意事项,非常有实用价值。
讲师:壞大叔bbUncle 中级 41725人正在学习
html滑动登录页面相关教程
- 2.3 登录页面模板 templates/login.html 登录页面 templates/login.html 显示一个登录表单,代码如下:<html><head> <meta charset='UTF-8'> <link href="https://lib.baomitu.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <link href="{{url_for('static', filename='style.css')}}" rel="stylesheet"> <title>登录</title></head><body> <div class="header"><i class='fa fa-sign-in'></i> 登录</div> <form action="/users/login" method="POST"> <div class="row"> {{ form.name.label }} {{ form.name() }} <b>{{ form.name.errors[0] }}</b> </div> <div class="row"> {{ form.password.label }} {{ form.password() }} <b>{{ form.password.errors[0] }}</b> </div> <div class="row"> {{ form.submit() }} </div> {{ form.hidden_tag() }} </form></body></html>登录页面 templates/login.html 与注册页面 templates/register.html 几乎完全相同,除了 title 标签不一样。请参考对 templates/register.html 的解释。
- 4.3 登录后的页面 创建second.xml,作为登录后页面的布局文件:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="170dp" android:textSize="20sp" /> <Button android:id="@+id/logout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="20dp" android:text="注销登录" /></LinearLayout>主要是一个欢迎页面,带上了用户的账号名,另外就是一个“注销登录”按钮,可以删除登录记录并跳转回登录首页,登陆成功后页面如下:
- 4.1 登录页面的编写 登录页面就是主页的 XML 布局文件,核心就是两个输入框,分别对应“账号”和“密码”,另外就是一个确认登录的 Button。<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/account" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="100dp" android:layout_marginTop="150dp" android:text="账号:" /> <EditText android:id="@+id/et_account" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="100dp" android:ems="10" /> <TextView android:id="@+id/password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="100dp" android:text="密码:" /> <EditText android:id="@+id/et_password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="100dp" android:ems="10" android:inputType="textPassword" /> <Button android:id="@+id/login" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="100dp" android:text="登录" /></LinearLayout>登录界面如下:
- 3.1 创建登录页面 <h1>用户登录</h1><form action="user/login" method="post"> 姓名:<input name="userLoginName" value="" type="text"> <br /> 密码:<input name="userPassword" value="" type="password"> <br /> <input name="btnLogin" value="登录" type="submit"> <input name="btnRe" value="重置" type="reset"></form>Tips: 当使用者点击登录按钮,发送登录请求之前,可以在客户端使用 JS 验证数据格式的合法性。既然是 OOP 编码,自然少不了构建用户类,此类的数据结构与用户表的表结构有对等关系。public class User { private Integer userId; //登录名 private String userLoginName; //真实姓名 private String userName; private String userPassword;}
- 1. 基于 Cookie 的自动登录 如果是想基于基本的 API 方式登录,我们会面临两大难点:手机验证码校验 ,如下图所示:起点网站登录手机发送验证码滑动验证码校验,如下图所示:起点网站登录滑动验证码绕过这些校验的方法超过了本教程的知识范围,故我们不再次详细讨论。好在起点网支持自动登录过程,也就是 Cookie 登录:起点网支持自动登录第一次手动登录起点,选择自动登录后,起点网站返回的 Cookie 信息就会保存至本地。下次再访问起点网时,通过请求带上该 Cookie 信息就能正确识别用户,实现自动登录过程。Cookie 存在本地,就存在被代码读取的可能。通常而言,我们来使用 Python 中的 browsercookie 库可以获取浏览器的 cookie,目前它只支持 Chrome 和 FireFox 两种浏览器。不过对于 Chrome 80.X 版本的浏览器,其中的 cookie 信息被加密了,我们无法按照早期的操作进行 cookie 读取。不过网上这个博客给出了一个解密 Cookie 的代码,我们拿过来简单改造下,做成一个辅助模块:# 参考文档:https://blog.csdn.net/u012552769/article/details/105001108import sqlite3import urllib3import osimport jsonimport sysimport base64from cryptography.hazmat.backends import default_backendfrom cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modesurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)def dpapi_decrypt(encrypted): import ctypes import ctypes.wintypes class DATA_BLOB(ctypes.Structure): _fields_ = [('cbData', ctypes.wintypes.DWORD), ('pbData', ctypes.POINTER(ctypes.c_char))] p = ctypes.create_string_buffer(encrypted, len(encrypted)) blobin = DATA_BLOB(ctypes.sizeof(p), p) blobout = DATA_BLOB() retval = ctypes.windll.crypt32.CryptUnprotectData( ctypes.byref(blobin), None, None, None, None, 0, ctypes.byref(blobout)) if not retval: raise ctypes.WinError() result = ctypes.string_at(blobout.pbData, blobout.cbData) ctypes.windll.kernel32.LocalFree(blobout.pbData) return resultdef aes_decrypt(encrypted_txt): with open(os.path.join(os.environ['LOCALAPPDATA'], r"Google\Chrome\User Data\Local State"), encoding='utf-8', mode="r") as f: jsn = json.loads(str(f.readline())) encoded_key = jsn["os_crypt"]["encrypted_key"] encrypted_key = base64.b64decode(encoded_key.encode()) encrypted_key = encrypted_key[5:] key = dpapi_decrypt(encrypted_key) nonce = encrypted_txt[3:15] cipher = Cipher(algorithms.AES(key), None, backend=default_backend()) cipher.mode = modes.GCM(nonce) decryptor = cipher.decryptor() return decryptor.update(encrypted_txt[15:])def chrome_decrypt(encrypted_txt): if sys.platform == 'win32': try: if encrypted_txt[:4] == b'x01x00x00x00': decrypted_txt = dpapi_decrypt(encrypted_txt) return decrypted_txt.decode() elif encrypted_txt[:3] == b'v10': decrypted_txt = aes_decrypt(encrypted_txt) return decrypted_txt[:-16].decode() except WindowsError: return None else: raise WindowsErrordef get_cookies_from_chrome(domain, key_list): sql = f'SELECT name, encrypted_value as value FROM cookies where host_key like "%{domain}%"' filename = os.path.join(os.environ['USERPROFILE'], r'AppData\Local\Google\Chrome\User Data\default\Cookies') con = sqlite3.connect(filename) con.row_factory = sqlite3.Row cur = con.cursor() cur.execute(sql) cookie_dict = {} for row in cur: if row['value'] is not None: name = row['name'] value = chrome_decrypt(row['value']) if value is not None and name in key_list: cookie_dict[name] = value return cookie_dictTips:上述这段代码不用纠结细节,前面函数的主要是替 get_cookies_from_chrome() 函数服务的,而该函数的输入要搜索的网站以及提取相应网站 cookie 信息中的某个具体字段,返回相应的结果。本人 Python 3.8.2 安装的是 win32 版本,该段代码亲测有效。来看看起点中文网给读者生成的 cookie 数据,我们调用上面的获取 cookie 信息的代码来从中提取相应数据:起点的cookie信息print(get_cookies_from_chrome('qidian.com', '_csrfToken'))print(get_cookies_from_chrome('qidian.com', 'e1'))print(get_cookies_from_chrome('qidian.com', 'e2'))执行上述代码我们可以得到如下结果:PS C:\Users\spyinx> & "D:/Program Files (x86)/python3/python.exe" c:/Users/spyinx/Desktop/test_cookie.py{'_csrfToken': 'YJklLmhMNpEfuSmqZZGaK72D4sUVJty52gyKwXXX'}{'e1': '%7B%22pid%22%3A%22qd_p_qidian%22%2C%22eid%22%3A%22qd_A08%22%2C%22l1%22%3A1%7D'}{'e2': '%7B%22pid%22%3A%22qd_p_qidian%22%2C%22eid%22%3A%22qd_A10%22%2C%22l1%22%3A1%7D'}这说明我们通过前面的代码能争取获取到起点网保存在 Chrome 浏览器中的 cookie 信息。因此,前面的代码将作为我们读取起点用户登录 Cookie 的重要辅助模块。Tips:这个测试只能在装了 Chrome 浏览器的 Windows 系统上进行测试,或者是 Linux 的桌面版我们首先来创建一个起点爬虫:PS C:\Users\Administrator\Desktop> scrapy startproject qidian_spider接下里我们来看看要提取的我的书架的信息:我的书架书籍信息对应的 items.py 的内容如下:# https://docs.scrapy.org/en/latest/topics/items.htmlimport scrapyclass QidianSpiderItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() # 分组 category = scrapy.Field() # 小说名 name = scrapy.Field() # 最新章节 latest_chapter = scrapy.Field() # 作者 author = scrapy.Field() # 更新时间 update_time = scrapy.Field() # 阅读进度 progress_status = scrapy.Field()接下来,在爬虫部分需要请求该页面然后提取相应的数据,我们的爬虫代码如下:"""获取用户书架数据"""import jsonfrom urllib import parsefrom scrapy import Requestfrom scrapy.spiders import Spiderfrom .get_cookie import get_cookies_from_chromefrom ..items import QidianSpiderItemclass BookCaseSpider(Spider): name = "bookcase" # 构造函数 def __init__(self): # 最重要的就是这个获取起点的cookie数据了,这里保存了之前用户登录的cookie信息 self.cookie_dict = get_cookies_from_chrome( "qidian.com", ["_csrfToken", "e1", "e2", "newstatisticUUID", "ywguid", "ywkey"] ) def start_requests(self): url = "https://my.qidian.com/bookcase" # http请求时附加上cookie信息 yield Request(url=url, cookies=self.cookie_dict) def parse(self, response): item = QidianSpiderItem() books = response.xpath('//table[@id="shelfTable"]/tbody/tr') for book in books: category = book.xpath('td[@class="col2"]/span/b[1]/a[1]/text()').extract_first() name = book.xpath('td[@class="col2"]/span/b[1]/a[2]/text()').extract_first() latest_chapter = book.xpath('td[@class="col2"]/span/a/text()').extract_first() update_time = book.xpath('td[3]/text()').extract_first() author = book.xpath('td[@class="col4"]/a/text()').extract_first() progress_status = book.xpath('td[@class="col5"]/a/text()').extract_first() item['category'] = category item['name'] = name item['latest_chapter'] = latest_chapter item['update_time'] = update_time item['author'] = author item['progress_status'] = progress_status print(f'get item = {item}') yield item最重要的方法就是那个获取 cookie 信息的方法了,正是靠着这个 cookie,我们才能获取相应的用户书架的网页并提取相应的书籍信息。接下来,简单实现一个 item pipeline 用于保存书架上的书籍信息,该代码位于 scrapy/pipelines.py 文件中,默认的 pipelines 都写会在这里:# 源码位置:scrapy/pipelines.py# Define your item pipelines here## Don't forget to add your pipeline to the ITEM_PIPELINES setting# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.htmlimport json# useful for handling different item types with a single interfacefrom itemadapter import ItemAdapterclass QidianSpiderPipeline: def open_spider(self, spider): self.file = open("bookcase.json", 'w+', encoding='utf-8') def close_spider(self, spider): self.file.close() def process_item(self, item, spider): data = json.dumps(dict(item), ensure_ascii=False) self.file.write(f"{data}\n") return item最后别忘了在 settings.py 中添加这个 item pipeline:ITEM_PIPELINES = { 'qidian_spider.pipelines.QidianSpiderPipeline': 300,}我们运行下这个爬虫,看看是否能抓到我们想要的数据:PS C:\Users\Administrator\Desktop> scrapy crawl bookcase最后的结果如下:获取用户的书架上书籍信息这样,我们就成功实现了用户登录后的访问动作。接下来我们在这个基础上进一步扩展,实现清除书架上所有的书籍,类似于淘宝的一键清除购物车。
- 3. 配置页面到 html 一般写 web 应用,会涉及到很多 html 文件,我们不可能将其全部都放在 Go 文件的字符串里,不方便调试的同时也影响代码维护。所以我们一般会直接加载 html 文件。代码示例:package mainimport ( "net/http" "text/template")func main() { http.HandleFunc("/index", index) //设置访问的路由 http.ListenAndServe("127.0.0.1:9300", nil) //设置监听的端口}func index(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { t, _ := template.ParseFiles("view/index.html")//加载html文件 t.Execute(w, nil)//将文件输出到浏览器 }}目录结构如下index.html 的代码如下:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>Go语言实战1</title></head><body> <div> <h3>登录</h3> <form> <div> <div> <input type="text" id="username" name="username" placeholder="请输入账号"> </div> </div> <div> <div> <input type="password" id="password" name="password" placeholder="请输入密码"> </div> </div> <div > <div > <button id="loginbtn" type="button" >登录</button> </div> </div> </form> </div></body></html>执行上述 Go 语言代码,在浏览器中输入127.0.0.1:9300/index。
html滑动登录页面相关搜索
-
h1
h6
hack
hadoop
halt
hana
handler
hanging
hash
hashtable
haskell
hatch
hbase
hbuilder
hdfs
head
header
header php
headers
headerstyle