![]() |
|
[C#] How To Save Value After Specific Text - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] How To Save Value After Specific Text (/showthread.php?tid=5937690) |
How To Save Value After Specific Text - Meterpreter - Feb 4, 2019 So I have managed to download a HTML page and save it, then save all lines containing my specific text. But say 50 lines containing the entire line with my keyword/key identifier in it, how can I take the value directly after that identifier? For example: <span class="class" id="pid_*some number I want* and in front of that is: "><a href= So it looks like: <span class="class" id="pid_*some number I want*"><a href= How would I go about get the *some number I want*?? I am new to C#, meaning I started today. I have spent a few hours googling, but to no avail. Any suggestions or resources are very much appreciated :) RE: How To Save Value After Specific Text - 0xDEAD10CC - Feb 4, 2019 Many ways, quick and dirty is regular string parsing or regex but keep in mind if the formatting changes that your regex should try to be as abstract as possible while still being specific enough that it grabs the right value off the page. There's other libraries out there for DOM parsing too, some people convert HTML to XHTML and use an XML parser... Just keep in mind that if the HTML is ill-formed, then these methods might not work that well either. Lots of people still use HTML agility pack as well, but AngleSharp as well (which I've never used before). RE: How To Save Value After Specific Text - Meterpreter - Feb 4, 2019 (Feb 4, 2019 08:45 PM)0xDEAD10CC Wrote: Many ways, quick and dirty is regular string parsing or regex but keep in mind if the formatting changes that your regex should try to be as abstract as possible while still being specific enough that it grabs the right value off the page. There's other libraries out there for DOM parsing too, some people convert HTML to XHTML and use an XML parser... Just keep in mind that if the HTML is ill-formed, then these methods might not work that well either. Lots of people still use HTML agility pack as well, but AngleSharp as well (which I've never used before). I had a look into regex but cant get it to work. I have parsed the entire html to a local file. Then streamread the file and found all lines containing what I want and save to its own file. So I have the lines but I literally need to say: Everything before pid_, ignore it, and everything after "><a href, ignore that too. And whatever is in between those two, save as a variable/array. RE: How To Save Value After Specific Text - 0xDEAD10CC - Feb 4, 2019 Well I gave you the options, how do you expect people to help you when you don't show any of your code? RE: How To Save Value After Specific Text - cristlol - Feb 4, 2019 Hope this one useful for you Code private void Form1_Load(object sender, EventArgs e)Output Code pid_123456789If have multilines you should parse it to Reader and Loop until the last line. RE: How To Save Value After Specific Text - Meterpreter - Feb 4, 2019 (Feb 4, 2019 09:33 PM)0xDEAD10CC Wrote: Well I gave you the options, how do you expect people to help you when you don't show any of your code? Here is my code: Code private void button1_Click(object sender, EventArgs e)(Feb 4, 2019 10:15 PM)cristlol Wrote: Hope this one useful for you After some tinkering it is working, this helped me a lot man, thanks for helping learn! Appreciate it. |