LUA提取免费迅雷账号

--获取http://www.521xunlei.com/ 免费迅雷账号

function getPageid()
	local http = require("socket.http")
	local url = "http://521xunlei.com/forum.php?mod=forumdisplay&fid=2&orderby=dateline"
	local resp = http.request(url)
	local s = string.find(resp, "<tbody id="normalthread_")
	local e = string.find(resp, "">", s)
	local pageid = string.sub(resp, s + 24, e - 1)
	return pageid
end

function getDatas()
	local urlpre = "http://521xunlei.com/thread-" 
	local url = urlpre .. getPageid() .. "-1-1.html"
	local http = require("socket.http")
	local html = http.request(url)
	local i = 1
	local usrstart, usrend, psdstart, psdend, temp_x, temp_y
	while(string.find(html, "爱密码迅雷会员共享", i))
	do 
		i, j = string.find(html, "爱密码迅雷会员共享", i)
		usrstart = j + 1
		usrend, temp_x = string.find(html, "独家分享密码", j)
		psdstart = temp_x + 1
		usrend = usrend - 1
		temp_y, _ = string.find(html, "</font>", temp_x)
		psdend = temp_y - 1
		print("用户名:" .. string.sub(html, usrstart, usrend) .. "   密码:" .. string.sub(html, psdstart, psdend))
		i = psdend
	end
end


print(getDatas())


--[[
按照发帖时间将帖子排序
http://521xunlei.com/forum.php?mod=forumdisplay&fid=2&orderby=dateline
最新帖子查找example:
<tbody id="normalthread_8901">
]]


--匹配的字符串有问题了,导致获取不到

参考一篇博文:http://blog.csdn.net/zhangxaochen/article/details/8084396

http://blog.csdn.net/ruiyiin/article/details/25953155

.  任意字符
 %s 空白符
 %p 标点
 %c 控制字符
 %d 数字
 %x 十六进制数
 %z 代表0的字符
 %a 字母
 %l 小写字母
 %u 大写字母
 %w 字母数字
字符类的大写形式代表相应集合的补集, 比如 %A 表示除了字母以外的字符集
另外,* + - 三个,作为通配符分别表示:
*: 匹配前面指定的 0 或多个同类字符, 尽可能匹配更长的符合条件的字串
+: 匹配前面指定的 1 或多个同类字符, 尽可能匹配更长的符合条件的字串
-: 匹配前面指定的 0 或多个同类字符, 尽可能匹配更短的符合条件的字串

于是, "(%a+)%s*=%s*(%a+)" 表示, 先匹配一个或多个字母, 然后是零个或多个空白符(比如空格), 然后是个 '=', 然后空白符, 然后字母。这样, 满足匹配的只有 "name = Anna"。 所以输出位置为 2 12.
因为捕获了两个 (%a+), 也就是 name, Anna 这两个单词, 所以还输出了这两个单词

代码更改为:

--获取http://www.521xunlei.com/ 免费迅雷账号

function getPageid()
	local http = require("socket.http")
	local url = "http://521xunlei.com/forum.php?mod=forumdisplay&fid=2&orderby=dateline"
	local resp = http.request(url)
	local s = string.find(resp, "<tbody id="normalthread_")
	local e = string.find(resp, "">", s)
	local pageid = string.sub(resp, s + 24, e - 1)
	return pageid
end

function getDatas()
	local urlpre = "http://521xunlei.com/thread-" 
	local url = urlpre .. getPageid() .. "-1-1.html"
	local http = require("socket.http")
	local html = http.request(url)	
	local title_x, title_y
	_, title_x = string.find(html, "<span id="thread_subject">");
	title_y, _ = string.find(html, "</span>", title_x)
	print("	" .. string.sub(html, title_x + 1, title_y - 1) .. "
")
	
	local html_x = string.find(html, "<td class="t_f"")
	local html_y = string.find(html, "</td>", html_x)
	html = string.sub(html, html_x, html_y)
	
		--[[
		<td class="t_f" id="postmessage_170571">...</td>
	]]
	
	local i,usrstart, usrend, psdstart, psdend
	i = 1
	while(string.find(html, "迅雷", i))
	do 
		i, _ = string.find(html, "迅雷", i)
		usrstart, usrend = string.find(html, ("(%w+):%d"), i)
		if(usrstart == nil or usrend == nil) then
			break
		end
		psdstart, psdend = string.find(html, "%d%d%d%d%d%d%d", usrend)
		if(psdstart == nil or psdend == nil) then
			break
		end
		i = psdend + 1
		print("账号:" .. string.sub(html, usrstart, usrend) .. "	密码:" .. string.sub(html, psdstart, psdend))
	end
end


print(getDatas())
os.execute("pause")

--[[
按照发帖时间将帖子排序
http://521xunlei.com/forum.php?mod=forumdisplay&fid=2&orderby=dateline
最新帖子查找example:
<tbody id="normalthread_8901">
]]


测试:


因为获取到的迅雷账号,不一定保证有效,所以要写一个批量登陆验证的脚本。(待续...)


方法:

1、获取窗口句柄

2、sendmessage实现

Keep it simple!
作者:N3verL4nd
知识共享,欢迎转载。
原文地址:https://www.cnblogs.com/lgh1992314/p/5834720.html