python webviewer爬虫_爬虫再也不怕检测浏览器环境了

背景

之前爬虫 驱动个 selenium 基本上就可以了.

但是现在各种检测浏览器环境...特别是不熟悉 js 的同学就更烦了

本文是直接把 selenium pyppeteer 以及正常打开浏览器 的环境差异直接列出来

这样你就可以更愉快的爬虫了(可以直接把环境全部模拟上,或者大概看看有啥,下次看人家混淆 js 的时候心里有个数)

原理

就是遍历 window 对象,把属性全部保存成 json 文件

function recur(obj) {

var result = {},

_tmp;

for (var i in obj) {

// enabledPlugin is too nested, also skip functions

if (i === 'enabledPlugin' || typeof obj[i] === 'function') {

continue;

} else if (typeof obj[i] === 'object') {

// get props recursively

_tmp = recur(obj[i]);

// if object is not {}

if (Object.keys(_tmp).length) {

result[i] = _tmp;

}

} else {

// string, number or boolean

result[i] = obj[i];

}

}

return result;

}

function go() {

var j = new Object();

var propertys = Object.getOwnPropertyNames(window);

propertys.forEach(element => {

if (element === 'globalThis' ||

element === 'Illegal' ||

element === 'parent' ||

element === 'top' ||

element === 'frames' ||

element === 'self' ||

element === 'window' ||

element === 'document'

) {} else {

eval("j." + element + "=recur(window." + element + ")")

}

});

console.log(JSON.stringify(j))

}

go()

然后分别正常打开,selenium 打开,pyppeteer 打开

再查看方法的差异

操作

获取 json

下载本项目

启动本地 server python -m http.server 80

打开 http://localhost/

正常打开最好是无痕模式,因为浏览器扩展可能会导致多出很多浏览器扩展的属性

打开网页以后 -> 打开开发者工具 -> 切换到 console

然后点击 copy,粘贴 json 到对应的文件内

{% asset_img aaaaa2.png %}

selenium pyppeteer 打开可以参考getEnvironment.py

比较

直接运行 python diff.py就可以了.

下面可以看到

差异有

root['navigator']['webdriver'], root['clientInformation']['webdriver'] 等等

这个算是目前检测用的比较多的,还有一些其他的可以自己运行看看

selenuim 与正常环境的差异

############################################################

{ 'dictionary_item_added': [root['cdc_adoQpoasnfa76pfcZLmcfl_Symbol'], root['cdc_adoQpoasnfa76pfcZLmcfl_Array'], root['cdc_adoQpoasnfa76pfcZLmcfl_Promise'], root['navigator']['webdriver'], root['clientInformation']['webdriver']],

'dictionary_item_removed': [root['chrome']['runtime'], root['navigator']['doNotTrack'], root['navigator']['languages']['2'], root['clientInformation']['doNotTrack'], root['clientInformation']['languages']['2']],

'type_changes': { "root['visualViewport']['height']": { 'new_type': ,

'new_value': 948,

'old_type': ,

'old_value': 751.2000122070312}},

'values_changed': { "root['clientInformation']['connection']['downlink']": { 'new_value': 1.3,

'old_value': 1.45},

"root['screen']['availHeight']": { 'new_value': 1027,

'old_value': 1050},

"root['screen']['availTop']": { 'new_value': 23,

'old_value': 0},

"root['visualViewport']['width']": { 'new_value': 840,

'old_value': 1344}}}

pyppeteer 与正常环境的差异

############################################################

{ 'dictionary_item_added': [root['WebKitAnimationEvent'], root['RTCRtpContributingSource'], root['SVGDiscardElement'], root['MediaCapabilitiesInfo'], root['WebKitTransitionEvent'], root['chrome']['webstore'], root['navigator']['webdriver'], root['clientInformation']['webdriver']],

'dictionary_item_removed': [root['BackgroundFetchManager'], root['RTCPeerConnectionIceErrorEvent'], root['WritableStreamDefaultWriter'], root['XRDOMOverlayState'], root['TrustedTypePolicy'], root['GeolocationCoordinates'], root['External'], root['ClipboardItem'], root['XRTransientInputHitTestSource'], root['XRRay'], root['PerformanceElementTiming'], root['XRViewerPose'], root['RTCError'], root['TextDecoderStream'], root['BackgroundFetchRegistration'], root['TrustedHTML'], root['onpointerrawupdate'], root['XRSession'], root['XRSessionEvent'], root['XRReferenceSpaceEvent'], root['XRReferenceSpace'], root['BarcodeDetector'], root['SubmitEvent'], root['AnimationEffect'], root['PeriodicSyncManager'], root['onformdata'], root['onselectstart'], root['TrustedScriptURL'], root['XRRenderState'], root['SpeechSynthesisErrorEvent'], root['RTCIceTransport'], root['TextEncoderStream'], root['MediaSession'], root['XRHitTestSource'], root['GeolocationPositionError'], root['XRPose'], root['XRView'], root['ElementInternals'], root['XRInputSourceArray'], root['XRInputSourceEvent'], root['XRFrame'], root['DecompressionStream'], root['TrustedScript'], root['Geolocation'], root['TrustedTypePolicyFactory'], root['XRBoundedReferenceSpace'], root['FeaturePolicy'], root['PerformanceEventTiming'], root['LargestContentfulPaint'], root['VideoPlaybackQuality'], root['onselectionchange'], root['XRSpace'], root['XRInputSourcesChangeEvent'], root['GeolocationPosition'], root['XRViewport'], root['XRHitTestResult'], root['queueMicrotask'], root['XRWebGLLayer'], root['DeviceMotionEventRotationRate'], root['ReadableStreamDefaultReader'], root['BackgroundFetchRecord'], root['LayoutShift'], root['DeviceMotionEventAcceleration'], root['MediaMetadata'], root['XRTransientInputHitTestResult'], root['PaymentMethodChangeEvent'], root['trustedTypes'], root['FragmentDirective'], root['UserActivation'], root['RTCErrorEvent'], root['CompressionStream'], root['XRRigidTransform'], root['Animation'], root['RTCSctpTransport'], root['XRInputSource'], root['FormDataEvent'], root['XRSystem'], root['EnterPictureInPictureEvent'], root['KeyframeEffect'], root['RTCDtlsTransport'], root['chrome']['runtime'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_OVERLAY'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_HUE'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_SATURATION'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_COLOR_DODGE'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_LUMINOSITY'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_EXCLUSION'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_DIFFERENCE'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_SOFT_LIGHT'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_HARD_LIGHT'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_COLOR_BURN'], root['SVGFEBlendElement']['SVG_FEBLEND_MODE_COLOR'], root['navigator']['userActivation'], root['navigator']['doNotTrack'], root['navigator']['mediaSession'], root['navigator']['languages']['2'], root['clientInformation']['userActivation'], root['clientInformation']['doNotTrack'], root['clientInformation']['mediaSession'], root['clientInformation']['languages']['2'], root['PerformanceObserver']['supportedEntryTypes']],

'type_changes': { "root['visualViewport']['height']": { 'new_type': ,

'new_value': 600,

'old_type': ,

'old_value': 751.2000122070312}},

'values_changed': { "root['clientInformation']['appVersion']": { 'new_value': '5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS '

'X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/71.0.3542.0 '

'Safari/537.36',

'old_value': '5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS '

'X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/83.0.4103.61 '

'Safari/537.36'},

"root['clientInformation']['connection']['rtt']": { 'new_value': 100,

'old_value': 150},

"root['clientInformation']['plugins']['0']['name']": { 'new_value': 'Chromium '

'PDF '

'Plugin',

'old_value': 'Chrome '

'PDF '

'Plugin'},

"root['clientInformation']['plugins']['1']['name']": { 'new_value': 'Chromium '

'PDF '

'Viewer',

'old_value': 'Chrome '

'PDF '

'Viewer'},

"root['clientInformation']['userAgent']": { 'new_value': 'Mozilla/5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS '

'X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/71.0.3542.0 '

'Safari/537.36',

'old_value': 'Mozilla/5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS '

'X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/83.0.4103.61 '

'Safari/537.36'},

"root['console']['memory']['jsHeapSizeLimit']": { 'new_value': 2330000000,

'old_value': 3760000000},

"root['history']['length']": { 'new_value': 2,

'old_value': 3},

"root['location']['href']": { 'new_value': 'http://localhost/',

'old_value': 'http://localhost/t.html'},

"root['location']['pathname']": { 'new_value': '/',

'old_value': '/t.html'},

"root['navigator']['appVersion']": { 'new_value': '5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/71.0.3542.0 '

'Safari/537.36',

'old_value': '5.0 '

'(Macintosh; '

'Intel '

'Mac '

'OS X '

'10_15_4) '

'AppleWebKit/537.36 '

'(KHTML, '

'like '

'Gecko) '

'Chrome/83.0.4103.61 '

'Safari/537.36'},

"root['navigator']['connection']['rtt']": { 'new_value': 100,

'old_value': 150},

"root['navigator']['plugins']['0']['name']": { 'new_value': 'Chromium '

'PDF '

'Plugin',

'old_value': 'Chrome '

'PDF '

'Plugin'},

"root['navigator']['plugins']['1']['name']": { 'new_value': 'Chromium '

'PDF '

'Viewer',

'old_value': 'Chrome '

'PDF '

'Viewer'},

"root['screen']['availHeight']": { 'new_value': 1027,

'old_value': 1050},

"root['screen']['availTop']": { 'new_value': 23,

'old_value': 0},

"root['screen']['colorDepth']": { 'new_value': 24,

'old_value': 30},

"root['screen']['orientation']['type']": { 'new_value': 'portrait-primary',

'old_value': 'landscape-primary'},

"root['screen']['pixelDepth']": { 'new_value': 24,

'old_value': 30},

"root['visualViewport']['width']": { 'new_value': 800,

'old_value': 1344}}}

项目地址

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/431429.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

jQuery: 整理2---操作元素的样式

1.获取元素的class属性值 attr("class") <div id"conBlue" class"blue larger">天蓝色</div>const cla $("#conBlue").attr("class") console.log(cla) // blue larger 2.设置元素的样式 attr("class…

matlab空间曲面拟合,matlab如何进行曲面拟合

matlab如何进行曲面拟合以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;在一丘陵地带测量高程&#xff0c;x和 y方向每隔100米测一个点&#xff0c;得高程如下表&#xff0c;试插值一曲面&am…

python做的游戏可以导出吗_Python for RenderDoc批量导出模型和贴图

故事背景&#xff1a;美术那里有需求&#xff0c;需要别人游戏的模型&#xff0c;来借鉴一下&#xff0c;问我是否有工具可以一键导出模型。我就搜索了一下RenderDoc批量导出图片&#xff0c;结果搜到了用C改RenderDoc源码的文章。让RenderDoc批量导出纹理_专栏-CSDN博客​blog…

treegrid.bootstrap使用说明

treegrid.bootstrap使用说明 这个插件是用来做有层次的表格的&#xff0c;大概如图&#xff1a; 官网 http://maxazan.github.io/jquery-treegrid/ 使用这个控件之前需要引入以下css及js&#xff08;因为用到了 bootstrap.js 所以加上了 bootstrap的样式和脚本&#xff09; bo…

matlab 条形图横坐标,Matlab条形图bar横坐标间距设置

1. 默认横坐标数据 X[x1, x2, x3, x4, x5, x6] %一行六列bar(X); %绘制基础条形图2. 修改横坐标标签#考虑横坐标标签文本较长且字体较大的情况bar(X);set(gca, xticklabels,{Apple, Orange, Banana, Pear, Pitaya, Lemon}, Fontname, Times New Roman, Fontsize, 16); %修…

成都python数据分析师职业技能_合格大数据分析师应该具备的技能

课程七、建模分析师之软技能 - 数据库技术本部分课程主要介绍MySQL数据库的安装使用及常用数据操作1、关系型数据库介绍2、MySQL的基本操作:1)数据库的操作2)数据表的操作3)备份与恢复3、常用的SQL语句:1)查询语句(SELECT)2)插入语句(INSERT)3)更新语句(UPDATE)4)删除语句(DELE…

项目属性--生成事件--后期生成事件命令行

以开源记牌器https://github.com/Epix37/Hearthstone-Deck-Tracker 为例&#xff0c;Hearthstone Deck Tracker项目中的后期生成事件命令行&#xff1a; if "$(ConfigurationName)" "Release" ( rmdir /S /Q "..\Hearthstone Deck Tracker" mkd…

大连理工优化方法matlab,大连理工大学2016年秋季优化方法大作业.pdf

优化方法期末上机大作业姓 名&#xff1a;李岚松学 部&#xff1a;电信学部电气工程学 号2016 年 11 月 9 日1最速下降法//最速下降法主函数//function llsdi1titidu(x)di1titidu(x)x0x; eps1e-4; k0; g0g(x0); s04; k0; g0g(x0); s0-g0;while (k>0)if norm(g0)break;elsela…

查看租户情况

source /root/openrc 查看keystone租户 keystone tenant-list 已知租户ID&#xff0c;获取租户名称 keystone tenant-get 5d95a18b92834ef2ada3abcf8eff1c83 查看某租户的配额及使用情况 # nova absolute-limits –-tenant ac9e6a9f-58c(租户ID)&#xff08;输出的内容不准确&a…

stm32 485和232可以用同一个串口吗_STM32的复用时钟何时开启?

STM32的AFIO时钟真的是在开启引脚复用功能的时候开启吗&#xff1f;其实并不是~什么是复用&#xff1f;我们知道&#xff0c;STM32有很多外设&#xff0c;这些外设的外部引脚都是与GPIO共用的。我们可以通过软件来配置引脚作为GPIO引脚还是作为外设引脚。当引脚配置为外设引脚时…

matlab 0-100随机数,添加到100的随机数:matlab

我经常看到这样的错误&#xff1a;要用给定的和来生成随机数&#xff0c;我们只需要使用一个一致的随机集&#xff0c;并且只需对它们进行缩放。但是&#xff0c;如果你这样做的话&#xff0c;结果真的都是随机的吗&#xff1f;在两个维度上尝试这个简单的测试。生成一个巨大的…

url中#号的作用

url中#号的作用就是本页面位置跳转 比如这个url地址&#xff1a;http://www.aaaaa.com/index.html?ad34&mc#red red就是index.html页面的依哥位置 浏览器读取这个URL后&#xff0c;会自动将red位置滚动至可视区域 位置定义方式 <a name"red">cdsc</a&…

python访问mysql_python连接mysql

首先需要导入驱动模块打开cmd导入模块 pip install mysqldb(pymysql)python2.x版本--------->mysqldbpython3.x版本---------->pymysqlpython调用MySQL数据库总共五步1、导入模块(驱动) pymysql mysqldb2、获取连接 connect3、获取游标cursor4、执行sql execute 并且返回…

php左侧菜单栏递归代码,js实现左侧菜单栏递归循环遍历

首先html布局菜单jsonconst menuList [{title: 首页,key: /home},{title: UI,key: /ui,children: [{title: 按钮,key: /ui/buttons,},{title: 弹框,key: /ui/modals,},{title: Loading,key: /ui/loadings,},{title: 通知提醒,key: /ui/notification,},{title: 全局Message,key…

重定向IO

引用自&#xff1a;http://www.cnblogs.com/liunanjava/p/4307793.html 1.三个静态变量 java.lang.System提供了三个静态变量 System.in&#xff08;默认键盘&#xff09;System.out(默认显示器)System.errSystem提供了三个重定向方法2.重写向方法 System提供了三个重定向方法 …

python三维数据本地保存_如何将3D Python/NumPy数组保存为文本文件?

如果保存文件需要是“csv”样式的文本&#xff0c;则可以使用多个savetxt和loadtxt。关键是要知道这两个都可以以打开的文件作为输入。写作示例&#xff1a;In [31]: Anp.arange(3*2*4).reshape(3,2,4)In [32]: A # normal display as 3 blocks of 2d arrayOut[32]:array([[[ 0…

php 简析对象,PHP白盒审计工具RIPS源码简析

RIPS是一款对PHP源码进行风险扫描的工具&#xff0c;其对代码扫描的方式是常规的正则匹配&#xff0c;确定sink点&#xff1b;还是如flowdroid构建全局数据流图&#xff0c;并分析存储全局数据可达路径&#xff1b;下面就从其源码上略探一二。1、扫描流程分析其源码前&#xff…

投资股权众筹项目,至少需要关注6个方面

1.股权结构去工商局查看这个公司的股权结构&#xff0c;哪些人是股东&#xff0c;历史出资情况。工商局网站上有很多信息可以查看&#xff0c;我发现北京工商局网站上可以查看的信息比较全面&#xff0c;而上海的就很稀烂。 几个查询网站&#xff1a; 北京企业信用信息网 ht…

python支持gui编程_Python GUI编程完整示例

本文实例讲述了python gui编程。分享给大家供大家参考&#xff0c;具体如下&#xff1a;import osfrom time import sleepfrom tkinter import *from tkinter.messagebox import showinfoclass dirlist(object):def __init__(self, initdirnone):self.top tk()self.label lab…

左右伸缩_冬季装修为啥要留伸缩缝?等到天热地板开裂就晚了!合肥人注意下...

后台有粉丝问&#xff1a;冬天真的不适合做装修吗&#xff1f;假的&#xff0c;这句话不要再传了。每个季节都会有利有弊&#xff0c;只不过冬季施工过程中干燥的比较快&#xff0c;装修的时候对施工要求的更严格。就拿伸缩缝来说吧&#xff0c;冬天装修时不注意&#xff0c;等…