js tutorial
What can JavaScript do?JavaScript can change HTML elements content. 123<p id="demo">JavaScript can change HTML content.</p><button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button> JavaScript can change HTML elements attributes. 123<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the...
JS逆向
Introduction网站为了防止客户随便对服务器发起请求,就会对在请求携带加密的校验参数,服务器要去验证这个参数后才会返回响应。JS逆向就是通过阅读JS代码,查看这个加密参数如何生成。然后我们在本地模拟还原JS生成相关参数,向服务器发送请求。所以JS逆向的根本解决点在于JavaScript代码。 找到目标数据的接口 找到加密位置 本地实现加密 网站代码运行时间轴加载html,加载js,用户触发事件,调用js,明文数据-加密函数-加密数据,发送XHR给服务器,接受服务器响应,解密函数,渲染 定位解密函数方法全局搜索 跟栈页面加载html, 加载JS代码 –> JS初始化(自执行函数) –> 用户触发事件 –> 调用JS –> 加密 –> 发包 –> 服务器 –> 接受响应 –> 解密 –> 刷新网页进行渲染 发包函数:从Initator中找到send, 或者在xhr断点中写入url路径 从发包往前跟: 由于发包是在加密之后, 可以在发包函数查看栈, 从而找到加密函数 从发包往后跟:...
正则表达式
Introduction在爬虫中,我们的目的就是要提取一大堆文本中的某些信息。我们就需要找到这些信息的共同特征,让计算机去匹配(match)。 正则表达式就是表达这些特征的重要手段。 一些特殊符号.: 表示除换行符之外的任意字符。 *: 表示前面的字符的0次到无限次,经过组合,就可以得到.*表示除换行符之外的任意多个字符。 ?: 表示前面的字符的0次或1次 +: 表示前面的表达式 出现 1 次或多次 \: 通过它可以让特殊符号成为普通符号,或者把普通符号变成特殊符号 \s*:跳过可能的空格 \d: (digital)表示一位数字 (): 提取里面的内容 (?:):非提取,某些爬虫可能会出现同一个数据,有多种不同的html文本格式,这是就需要搭配或者符号|。比如:(?:a|b)匹配a或者b .*:贪婪模式,获取最长的满足条件的字符串。 .*? :非贪婪模式,获取最短的能满足条件的字符串。 python中的正则表达式re是python中的正则表达式模块 findall以列表的形式返回所有满足正则表达式的字符串。 1re.findall(pattern, string,...
python模拟ajax请求
Introduction经过大众好评的书籍的阅读,还有chatgpt的帮助,我成功完成了第一次ajax请求。 总的来说,ajax请求的来源就是: 由最原始的request URL直接暴露在源代码中,为了防止爬虫轻易地实现自动化自动抓取数据,从而把请求隐藏在JavaScript中(这种请求也叫Ajax请求),Ajax请求可以干很多东西,可能是直接response内容,也有可能是改变用户的状态,等等。从而避免了直接的URL获取。 查看JavaScript源代码,看看他在背后做了什么(发送ajax请求?获取源代码中的隐藏变量?改变用户状态?) 通过request模拟ajax请求, 通过触发事件,在浏览器开发者工具中,找到这个Ajax请求(通常是post,需要传递相关参数才能传递),并发送 (总之,就是通过python干JavaScript干的事情) 最终,我得到了想要的数据 JS分析1<p class="erphpdown-content-vip erphpdown-content-vip-see">您可免费查看此隐藏内容!<a...
A Django Project
How to begin a project?We learned Django basic usage before. The most important thing is how to begin a Django project based on the knowledge we just learned? The answer is that we need a godfather. The godfather helps us build a Django project from the begin to the end. Frontend with BootstrapAfter we start a Django project, we start an app blog in the project. To begin with, what we have to create is a surface, the frontend. blog/urls.py 1234567from django.urls import pathfrom ....
vue3 tutorial
单文件组件单文件组件 (也被称为 *.vue 文件,英文 Single-File Components,缩写为 SFC) Vue 的单文件组件会将一个组件的逻辑 (JavaScript),模板 (HTML) 和样式 (CSS) 封装在同一个文件里。 创建一个 Vue 应用这一指令将会安装并执行 create-vue,它是 Vue 官方的项目脚手架工具 1npm create vue@latest 创建完成后, 安装依赖并启动服务器 123cd <your-project-name>npm installnpm run dev 基础响应性ref()当一个组件首次渲染时,Vue 会追踪在渲染过程中使用的每一个 ref。然后,当一个 ref 被修改时,它会触发追踪它的组件的一次重新渲染。 Ref 可以持有任何类型的值,包括深层嵌套的对象、数组或者 JavaScript 内置的数据结构。Ref 会使它的值具有深层响应性。这意味着即使改变嵌套对象或数组时,变化也会被检测到。 也可以通过 shallow ref来放弃深层响应性。对于浅层 ref,只有 .value...
css tutorial
CSS ruleA CSS rule consists of a selector and a declaration block. Selector element selector The element selector selects elements based on the element name. 1234h1{ color: white; text-align: center;} Now all the h1 will be center-aligned, with while color. id selector The id selector uses the id attribute of an element to select an element. 1234567891011121314151617<!DOCTYPE html><html><head><style>#para1 { text-align: center; color:...
Django Basic
How to build a websiteA website contains three parts which are a web server, a web application(Django), and a database. When user enters a URL in browser, a request is sent to the web server. Then, the server accepts the request and takes it to the web application through WSGI port. After web application dealing the request with database, the results are sent to the web server by WSGI port. Finally, the sever packages the results into a response and return it to user’s browser. Website...
Django Tutorial
What you have to know before you get startedThe thing you have to know before learning it is how it works. Suppose a server is running a Django app. Firstly, Django loads the setting.py file to initialize configurations like database connection. Then, Django opens a port 8000 by default, waiting for http requests. Once a request comes in (for example, when a user enters a URL in the browser), Django looks for the URL in the urls.py file. If it finds a match, the request is directed to a...
mitmproxy App爬虫
安装什么内容?首先让pc和手机连接同一个局域网,在pc上安装好mitmproxy并安装好证书后,还要在安卓手机的设置中心也安装好证书,并设置代理(通过ipconfig命令查看主机的ip地址,) 这样我们就可以在使用mitmproxy这个代理了。 开始工作在terminal开启代理,指定为8888端口 1mitmproxy -p 8888 或者我们可以用mitmdump可以对接python脚本 1mitmdump -s script.py -p 8888 当手机连上代理后, 此时,手机上的request和response都被代理抓取了下来,
