VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > python爬虫 >
  • python爬虫 - js逆向解密之简单端口加密破解v2 -- 修复版

前言

这篇跟上一篇很像,而且他的端口显示也很类似,是的,它也是一个国外的代理网站

分析

打开网站查看:

 

 

 

发现它的的端口和之前的网站一样,不是直接显示的,那么用SmallProxy这个关键词搜索下在哪,很快就找到了下面这个:

 

 

 

 

关键点

 

代码:

<script type="text/javascript">
//<![CDATA[
  Xinemara = 2051;BigBlind = Xinemara^42776;DexterProxy = Xinemara^19605;BigGoodProxy = 26194^DexterProxy;Defender = 18662^BigGoodProxy;SmallProxy = 32206^BigGoodProxy;SmallBlind = 24500^Defender;Agile = Defender^BigGoodProxy;ProxyMoxy = 31100^Agile;BigProxy = 35563^SmallProxy;DontGrubMe = BigProxy^BigProxy;NineBeforeZero = 40710^14588;Xorg = SmallProxy^57660;Socks = 61653^27735;HttpSocks = BigBlind^DexterProxy;GrubMe = 1176^45424;Polymorth = 23590^54130;
//]]>
</script>

 

代码实现

 

好的,废话不多说了,主要用了exec和eval,直接给代码了,因为之前一篇文章分析过了,就不再详细说了

 

复制代码
import requests
from lxml import etree
from lxml.html import tostring
from bs4 import BeautifulSoup, Comment

HEADERS = {
    'sec-ch-ua': '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'cross-site',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'Connection': 'close',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
}

url = ''  # 保密

req = requests.get(url, headers=HEADERS)
res = req.content.decode('utf-8')
html = etree.HTML(res)
end = []
data = html.xpath('//table[@class="proxytbl"]/tr[position()>1]')
key = html.xpath('//noscript/preceding-sibling::script[1]/text()')
key = ''.join(key).replace('//<![CDATA[','').replace('//]]>','').strip() if key else ''
exec(key.strip())
for item in data:
    ip = item.xpath('./td[1]/text()')
    ip = ''.join(ip) if ip else ''
    port_temp = item.xpath('./td[2]/script/text()')
    port_temp = ''.join(port_temp) if port_temp else ''
    port_temp = port_temp.replace('document.write(', '').replace(');', '').replace('//<![CDATA[','').replace('//]]>','').strip()
    port = eval(port_temp)
    print(12313213,ip,port)
    # if ip and port:
    #     proxy = ip + ":" + port
    #     end.append(proxy)
print(12312, len(end), end)
复制代码

 

网址就保密了哈,想要的私信我

 

结语

 

这个也挺简单的哈,还是那句都不叫加密。我觉得凡是还是多分析吧,别看到什么js就怕了,可以多看看,就算搞不定,也要看看能走到哪里,然后去恶补这方面的知识,下次遇到也就可以搞定了

出处:https://www.cnblogs.com/Eeyhan/p/15293236.html


相关教程