Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Retrieve 2 dynamic value from HTTP Response

hi Guys,

I need a little Help regarding retrieving 2 dynamic values from Http Web Response content.

I save response content in page.html and use HTML agility pack to retrieve some values example

Response
Code
<input name="static" value="dynamic">

my code
Code
doc.Load(Application.StartupPath + @"\\page.html");
string abc = doc.DocumentNode.Descendants("input").First(i => i.Attributes["name"] != null && i.Attributes["name"].Value == "static").Attributes["value"].Value;

but i need help for a this Response
Code
<input name="static:dynamic" value="dynamic">

1. I cant use above code as that wouldn't work
2. whole response has 1173+ line so regex is taking too much time to read
3. Also this
Code
<input name ="static
this occurs 15 time in whole response content...

So is there any way how can i get both dynamic values

Please help
You can use LoadHtml and not save it to file, other than that, try finding it by XPath.
[Image: IqcFmkW]
PHP Code

<?php 
new Regex('<input name="static" value="(.*?)">', new WebClient().DownloadString("http://google.com/page.html")).Match.Group[1].Value; 
I only use https://ricochet.im - ricochet:lmi3tdtlsnziqwdk

Jabber: [email protected]
(Feb 11, 2016 11:37 AM)stackoverflowin Wrote:  
PHP Code

<?php 
new Regex('<input name="static" value="(.*?)">', new WebClient().DownloadString("http://google.com/page.html")).Match.Group[1].Value; 

Jesus christ. What a mess, I thought you was a pro? Nice memory leak.
@StackOverlowin
That is a pretty inefficient way of doing it, as XPath can be used directly.
(Feb 11, 2016 10:37 AM)Benoit ᵇᵃˡˡˢ Wrote:  You can use LoadHtml and not save it to file, other than that, try finding it by XPath.

I need Response content in page.html to find out if some error occur while running so i got to know where my error is coming from.
I'll try xpath Thanks but a example code would be nicer..

(Feb 11, 2016 11:37 AM)stackoverflowin Wrote:  
PHP Code

<?php 
new Regex('<input name="static" value="(.*?)">', new WebClient().DownloadString("http://google.com/page.html")).Match.Group[1].Value; 

I already wrote that response content has over 1173+ lines so regex is taking too much time to read every line + if you had noticed
Code
<input name="static:[b]dynamic[/b]" value="dynamic">
(Feb 11, 2016 12:00 PM)+Haze Wrote:  Jesus christ. What a mess, I thought you was a pro? Nice memory leak.

Yes, nice memory leak with a CLR that removes anonymous class instances as soon as they go out of scope.
(Feb 11, 2016 10:37 AM)Benoit ᵇᵃˡˡˢ Wrote:  You can use LoadHtml and not save it to file, other than that, try finding it by XPath.

Hi i did some google how to use that but i think xpath can be used with tags and all like list or table etc....
but there is no table or list...

just
Code
</table><input type="hidden" name="static:dynamic" value="dynamic"><input type="hidden" name="static">....

Please A little bit more help would be great
(Mar 9, 2016 12:22 PM)Electroalek Wrote:  I would actually suggest a custom find method. You probably know approximately where that input element is in the whole document. So just loop within that range and do a manual look-ahead for the needed characters, if you can find them parse the value that way. This way you will keep the find cost low. Of course you can do a substring from a smaller portion, again the approximate location of the input element and then use regex on it, instead of the whole string. With the first method you can also use a streamreader and directly read as it downloads the stream, so it will be super efficient.

Thanks for reply..
I did that what you ask but unfortunately all other input tag elements are in same table where my required data is but it is in last of that table tag.
So can you tell how to just neglect rest input tag and just read last input tag in table tag.
May I have the full site url so that I can try this?
(Mar 18, 2016 10:40 AM)Verizur Wrote:  May I have the full site url so that I can try this?

Bro I send a skype request to your following signature name.

BTW it's a response code so if i share url it wouldn't work according to needed.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by 3oxicMar 11, 2019 11:56 AM 3 250 Mar 11, 2019 11:56 AM
Last Post: HFDone
[.NET] by pap.iOct 7, 2016 09:56 PM 10 285 Oct 7, 2016 09:56 PM
Last Post: deiski
[Python] by hunter122May 22, 2015 02:45 PM 2 186 May 22, 2015 02:45 PM
Last Post: hunter122