匹配值Lua
得到了这个答案。
<div class="executor-item--btns">
<form name="UserResetAccount" onsubmit="event.preventDefault(); return false;">
<input type="hidden" name="UserResetAccount[nonce]" value="68a7c22f1d">
<input type="hidden" name="UserResetAccount[network]" value="1">
如何从“ userresetaccount [nonce]“ value =“ this value”
)获取值 从使用
string.match
? 感谢你
got this get answer.
<div class="executor-item--btns">
<form name="UserResetAccount" onsubmit="event.preventDefault(); return false;">
<input type="hidden" name="UserResetAccount[nonce]" value="68a7c22f1d">
<input type="hidden" name="UserResetAccount[network]" value="1">
how to get value from "UserResetAccount[nonce]" value="THIS VALUE"
and from "UserResetAccount[network]" value="THIS VALUE"
using string.match
?
thank u
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法充分用正态表达式解析html 。 LUA模式在某些方面(但在其他方面也稍弱)比正则表达式更强大(但在其他方面也稍弱),但仍然不足以完全解析HTML。使用图案或正则表达式的所有内容必将失败,以获取更复杂或精心设计的文档。
您应该使用适当的html解析器,例如 gumbo 。根据您使用的解析器,您可以使用XPATH或CSS选择器(
input [name =“ userresetaccount [nonce]”]
)来获得该input> input
element> element(element> element(如果使用Gumbo,则可以使用getElementsByTagName(“ Input”)
,然后在元素列表上循环以搜索name ==“ userresetaccount [nonce]
> )。You can't adequately parse HTML with regular expressions. Lua patterns are slightly more powerful in some aspects (but also slightly weaker in other, more basic ones) than regular expressions yet still not powerful enough to fully parse HTML. Everything using patterns or regular expressions is bound to fail for more complex or specially crafted documents.
You should use a proper HTML parser such as Gumbo. Depending on the parser you use, you might use XPath or CSS selectors (
input[name="UserResetAccount[nonce]"]
) to obtain the value of thatinput
element (if you use Gumbo, you can usegetElementsByTagName("input")
and then loop over the element list to search for the element withname == "UserResetAccount[nonce]"
).使用
string.gmatch
此方式:带有示例输出:
with
string.gmatch
this way:with your example output: