|
gleat you are amazing! Thank you very much! I am going to try to make this work. I am sure I will have some questions but I am going to work with this a while first.
|
|
|
|
|
Gleat, thanks again for your program. The only thing that is different in the situation I described is that the postdata values are not known when the program is run. You gave me the info I needed to look that up so all is good.
For the benefit of any one else who is trying to do this:
Download a program called Fiddler from www.fiddler2.com.
Open fiddler then use your web browser to click the elements on the page you are trying to automate. Observe the data posted back to the server. The ParseDocument function you write (see code below) will need to create a string that matches the postdata.
Here is the code you can run to automate your page. Create a form with a textbox and a button. Paste the code below as the form class. The ParseDocument function is specific for my purpose. I included it to demonstrate the basic foreach loop and id test.
<code>
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
string url = textBox1.Text;
IHTMLDocument2 doc = new HTMLDocumentClass();
WebRequest request1 = WebRequest.Create(url);
WebResponse response1 = request1.GetResponse();
StreamReader reader = new StreamReader(response1.GetResponseStream());
doc.write(reader.ReadToEnd());
doc.close();
response1.Close();
string postdata = ParseDocument(doc);
WebRequest request = WebRequest.Create(url);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
((HttpWebRequest)request).Referer = url;
using (Stream stream = request.GetRequestStream())
{
stream.Write(Encoding.UTF8.GetBytes(postdata), 0, Encoding.UTF8.GetByteCount(postdata));
stream.Flush();
}
WebResponse response = request.GetResponse();
using (FileStream dest = new FileStream(GetFilename(response), FileMode.Create))
{
using (Stream src = response.GetResponseStream())
CopyStream(src, dest);
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: {0}", ex.ToString());
}
}
private static string GetFilename(WebResponse response)
{
string filename = response.Headers["Content-Disposition"];
if (filename != null)
{
string[] tokens = filename.Split(';');
if (tokens.Length == 2)
{
tokens = tokens[1].Split('=');
if (tokens.Length == 2)
filename = tokens[1];
else
filename = null;
}
else
filename = null;
}
if (filename == null)
{
filename = response.Headers["Content-Type"];
if (filename != null)
{
string[] tokens = filename.Split(';');
if (tokens.Length == 2)
{
tokens = tokens[1].Split('=');
if (tokens.Length == 2)
filename = tokens[1];
else
filename = null;
}
else
filename = null;
}
}
if (filename == null)
filename = "ding.dat";
return "c:\\" + filename;
}
private static void CopyStream(Stream src, Stream dest)
{
byte[] buffer = new byte[1024];
int read = -1;
while (read != 0)
{
read = src.Read(buffer, 0, buffer.Length);
if (read != 0)
dest.Write(buffer, 0, read);
}
}
public string ParseDocument(IHTMLDocument2 doc)
{
string postdata = "_qf__mainform=";
foreach (mshtml.IHTMLElement pageElement in doc.all)
{
string id = String.IsNullOrEmpty(pageElement.id) ? " " : pageElement.id;
if (id == "selected_vintage_dates")
{
string[] x;
x = pageElement.innerText.Trim().Split(new Char[] {' '});
for (int i = 0; i < x.Length; i++)
{
postdata += "&selected_vintage_dates%5B%5D=" + x[i];
}
break;
}
}
postdata += "&entered_vintage_dates=&file_type=1&file_format=xls&download_data=Download+Data";
return postdata;
}
}
</code>
|
|
|
|
|
hi,
can any body help me while posting the difference between .net framework 1.1 and 2.0?
Thanks
--Krish
prfkrushna@gmail.com
|
|
|
|
|
Many differences.
1- Partial classes in .NET 2.0
2- Generics in 2.0
3- Many more classes.
Check this[^] to get an idea
|
|
|
|
|
hi
i feel it's not that much enough in the interview point of view.
it's better u pls help me some more extent.
otherwise if any written document is there, pls send it to my mail id:
prfkrushna@gmail.com
Thanks
--Krish
prfkrushna@gmail.com
|
|
|
|
|
0.9
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Now lets play a game of Find the egg.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
IIRC a couple of days ago the egg was in the middle of a big red circle, part of a traffic
control system. Not sure it is still there though.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
"They seek it here. They seek it there. They seek that egg everywhere." This poem comes to you courtesy of John Simmon's YerAnus.;)
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Luc Pattyn wrote: the egg was in the middle of a big red circle
If there was a hailstorm, it would have got damaged right?
Vasudevan Deepak Kumar
Personal Homepage
Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
Don't know, it could have been hard boiled or so.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Wait for me.... I ran out of chalk!
|
|
|
|
|
led mike wrote: I ran out of chalk!
You can borrow mine. I've used it to mark out the sacrifice area.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Good one!
Vasudevan Deepak Kumar
Personal Homepage
Tech Gossips
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
"You posted your question here, indicating that you're so thick you couldn't find the VB Forum if it was licking your bung hole." - John Simmons / outlaw programmer
|
|
|
|
|
|
Ahhh - you went and spoiled all the fun.;P
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
We are a French compagny, we need to find freelance compétence in paris to help us with the projects that we have with our customers.
Dont hésitate to contact me as soon as possible.
Hicham Sipkin
S.G.U.I
61 bld National
92250 La Garenne Colombes
email : hicham.sipkin@sgui.fr
Tél : + 33 1 47 69 60 02
Fax : + 33 1 47 69 60 10
portable : 06 80 64 45 14
http://www.sgui.fr
http://www.sguionline.com
http://www.pasa.fr
Bonsoir,
Je suis tombé par hasard d'un surf sur votre site web. Je suis à la recherche de compétence pour intervenir très rapidement sur de petits developement sharepoint que nous effectuons chez nos client ( intranet note de frais, gestion de congés, etc...) Notre dévelopeur est complétement submergé par les projets en cours. Nous serions interressé par des interventions rapide dans les jours ou semaine qui arrivent. Voir une mise en relations pour les futurs projets d'intranet.
Si jamais vou
|
|
|
|
|
This isn't the forum for this. If you want to advertise for staff, consider using this[^] forum.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Post in the job board on this site. Don't use word like urgent, it is rude around here.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have a web service that's got methods that has a return type of XlmDocument . However, when I get the return value in the app that consumes the web service, the return value is of type XmlNode . Yes, I've verified that the method itself is really returning a XmlDocument object. Why does it do that?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Unfortunately, that's just standard behaviour. .NET marshalls XmlDocuments as XmlNodes across SOAP. This isn't really an issue because an XmlDocument is a subclass of XmlNode. To load the node back into a document, do this:
XmlDocument doc = new XmlDocument();
doc.LoadXml(MyWebService.Method().OuterXml);
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
5
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I want to create one MSI Package with following requirement
1)There should not be any entry in Add Remove entry, Control Panel
2)The MSI package should use ASMFlag.sys file in C root to determine if the agent is installed or not. If file exists, do not install. If file does not exist, install.
3) When MSI package is created, the EXE will reside in a subfolder named 'temp'.
This is very urgent requirement. Please suggest how to create MSI Package.
Thanks in Advance
|
|
|
|
|
Cross post. Please ignore this thread.
Deja View - the feeling that you've seen this post before.
|
|
|
|