出师不利还是学艺不精?IT行业薪资节节高,没有,

[复制链接]
查看891 | 回复0 | 2022-11-20 19:38:03 | 显示全部楼层 |阅读模式
脚本之家

你与百万开发者在一起

这是1个发生在身边的事情,都说IT行业薪资节节高,没有最高,只有更高。可是在外人看来又有谁了解其中的内幕。

看似不错薪资的背后,是在无数加班通宵的日子中度过。还要时不时与项目经理、产品经理甚至不懂技术的BOSS周旋,可谓九死一生。

出师不利还是学艺不精?

朋友小A是个多年的IT研发工程师,近期换了份的工作。刚到岗2天,项目经理就跟小A说了20分钟他的设想,让小A能根据他刚才说的内容编写出一套通用框架。小A认为在业务不甚熟悉的情况,很难完成这个任务,于是项目经理就给他布置了个爬虫的任务。按照小A之前的工作经验,这样的任务对他来说就是小菜一碟。于是便很愉悦的答应了下来。

结果,那天晚上下班后,项目经理便Q留言,怎么这么早就下班了。然后询问下东西的进度,是否能在明天就交付,因为这个项目开发周期很赶。希望能在尽快完成。

为了留下个好的印象,小A牺牲了与女朋友约会的时间,在当天晚上干到了凌晨1点总算完成了整体80%的工作量。于是第2天早上稍作整合,就完成交付了。

结果,第2天早上项目经理二话不说,让小A在原有的基础上添加自动化的功能。要用1个selenium的库通过浏览器的方式自动填写相关内容,并在存在相关控件的时候能够填入对应的内容,并提交。幸亏这个所谓的selenium上手很容易,小A花了1个早上又顺利的完成了相关布置的任务。

不合理的开发周期

下午,项目经理希望能在原有的基础上获取到访问的URL的请求头信息和响应头信息,对于Python的requests库来说,真心很简单,直接通过下面的方式就可以了:

<p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(23, 28, 25);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei"!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;">    <ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">import</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> requests</span></code></span></span>
</li><li><br  />
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">url </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"访问的URL地址"</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">req </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> requests</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">get</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">url</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">print</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">req</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">headers</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></span>
</li></ol></pre></p>
然而,由于该方面不是selenium的核心。因此,selenium并不提供相关的API可以直接调用。此时,一种可行的方式是通过将浏览器请求转发给本地端口上的1个代理,而在代理上获取它的请求。

晚上,项目经理又在Q上留言,说现在项目在赶进度,怎么又这么早就下班了。 之后又询问项目的进度如何,能不能在明天中午之前赶出一个版本。

由于之前面试的时候,小A说了很多项目经理不懂的术语。加上小A多年的开发经验,项目经理觉得这样的需求只要1天就能完成了。而在任务开始的时候,却片字不提期望完成的效果及时间,反以一句尽快进行答复的任务往往都是凶多吉少。

在小A的开发生涯中,1天要完成几个之前都没有接触到的东西,是不大现实的事情。

纠结情怀作怪

为了确保进度能正常进行。之后,项目经理给了小A一份之前同事编写1个模块,通过ThreadHTTPServer实现的单个脚本,而后来才发现是github上proxy2的源码。但是,神奇的是,这代码只能在Linux上运行,如果在Windows上要么浏览器闪退,要么程序直接崩溃。

于是,小A找了个BrowserMobProxy的代理工具,该工具可以与Selenium配合使用来完成对应URL地址请求的获取,而在其基础上稍作封装才完成对应请求头信息的获取。小A当时很高兴,觉得这次总算有1个可以交付的产出物。其相关的代码只需要6行就可以完成:

<p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(23, 28, 25);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei"!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;">    <ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">server </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> </span><span class="typ" style="box-sizing: border-box;color: rgb(71, 140, 144);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Server</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">server</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">start</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">proxy </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> server</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">create_proxy</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()</span></code></span></span>
</li><li><br  />
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">...</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">proxy</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">new_har</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'xxx'</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                      </span><span class="com" style="box-sizing: border-box;color: rgb(95, 109, 100);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#在需要获取的地方插入这行</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">for</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> ent </span><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">in</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> proxy</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">har</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[</span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'log'</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">][</span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'entries'</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">]:</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">   </span><span class="com" style="box-sizing: border-box;color: rgb(95, 109, 100);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#分析HAR的内容</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="kwd" style="box-sizing: border-box;color: rgb(85, 133, 155);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">print</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">ent</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[</span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">'request'</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">])</span></code></span></span>
</li></ol></pre></p>
于是,事情在小A跟项目经理说明难处之后发生了转变。项目经理觉得要上传20多M的文件,有点大。而且还要提供Java的运行环境,过于麻烦。而项目经理对Java不大熟悉,因此认为这个方案不可行。希望小A在之前同事原有基础上进行修改,并让其正常运行。

一波未平一波又起

又是1个晚上,总算把程序给调通了。此时小A的心里稍微平静了下,这下总算可以交付了。

结果第2天早上,项目经理又找到了小A,询问了下工作的进度。小A只好一五一十的说明情况,并跟项目经理说同事抓取不了HTTPS的包。项目经理直接回了一句,怎么可能,之前同事的代码在Linux下HTTPS的包是完成没有问题的。说到这里,小A心里有点疑惑。为了让自己消除疑惑,小A让项目经理演示下其操作过程,结果还真的可以在Linux下抓取到HTTPS。

于是,小A让项目经理把线上的代码下载下来,项目经理直接说那就是之前给你的那份。基本上不怎么改动,只是稍微加了一些功能。结果发现,在初始化浏览器之前的时候有这么一行关键代码:



<p><pre class="prettyprint linenums prettyprinted" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(23, 28, 25);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, "Microsoft Yahei"!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;">    <ol class="linenums list-paddingleft-2" style="list-style-type: none;"><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">profile </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> webdriver</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="typ" style="box-sizing: border-box;color: rgb(71, 140, 144);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">FirefoxProfile</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="str" style="box-sizing: border-box;color: rgb(72, 153, 99);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"/root/xxxx/随机8个字符"</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">...</span></code></span></span>
</li><li><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><span style="box-sizing: border-box;display: block;word-break: inherit !important;"><code style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">browser </span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> webdriver</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="typ" style="box-sizing: border-box;color: rgb(71, 140, 144);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Firefox</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">firefox_profile</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">=</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">profile</span><span class="pun" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span><span class="pln" style="box-sizing: border-box;color: rgb(236, 244, 238);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">  </span><span class="com" style="box-sizing: border-box;color: rgb(95, 109, 100);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">#初始化浏览器</span></code></span></span>
</li></ol></pre></p>
一般情况下,在初始化1个火狐浏览器的FirefoxProfile时候是不会传入相关参数的。而这里,恰恰有这么一行内容,是不是HTTPS在Linux下可以获取到HTTPS的请求跟它有关系呢。

于是为了进一步验证自己的想法是对的,小A搭建1个Linux的环境。结果大跌眼镜,同事之前的代码在Linux下也是无法获取到HTTPS请求的。于是又跟项目经理反馈了问题,项目经理说缺少相关证书。此时才缓缓的传了几个PEM格式的证书给小A,确实添加了证书之后是可以获取到HTTPS的请求。但是,获取的请求跟请求的页面URL地址完全不搭边,基本都是什么火狐链接的。

换句话说,之前在项目经理电脑上看到的HTTPS请求根本就不能重现。如果某一天,他那服务器宕机或重装,获取到的HTTPS请求基本都是跟当前访问的页面是不搭边的。

这也解释了,为什么之前项目经理说在Windows上运行不起来,只有在Linux上才能实现的问题。不排除,这本来就是个BUG,1个写死了的代码。

最后,项目经理希望小A能尽快解决这个问题,解决在任意Linux上都可以不做修改的情况下获取到HTTPS的请求头信息。 于是小A直接让项目经理在本地浏览器上安装相关的证书,将其导出并在初始化浏览器的时候指定相关的文件,总算解决了之前的一系列问题。

待续

于是1个星期过去了,小A看似完成了相关的任务。接着项目经理总结说到,这个星期项目进展有点慢,跟期望的进度有差距,希望小A能体谅,主动地加班。这样,才能确保项目正常的进行。

此时的小A决定,不再花费自己的私人时间折腾这种公司工作上的事情。有时间还是多跟女朋友交流下感情比较妥当。

本文作者:风中纸鹞,1个多年滚打于Web开发的研发工程师。熟悉PHP、Java、C++等编程语言,以编程作为乐趣。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则