Can you point me to a keyword or something I plug into google to get more specific info? Thanks
swheat
Posts
-
how to created object referenced by a string -
how to created object referenced by a stringDoes any one know how to do this? I want to set object y equal to object x. I only know the name of x because it's name is contained in someString. object x = new object(); string someString = "x"; // string set to object name //problem is here: object y = (the object whose name is contained in the variable someString i.e. "x") In case you are wondering why I need such a thing.... In my app someString is actually looked up in a table. It's a long story, as usual.
-
IE automation questionGleat, 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.
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 { // Create a web request for the initital query to get post values 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(); // Loop through the html document elements to get postdata values string postdata = ParseDocument(doc); // // create a web request for our page // WebRequest request = WebRequest.Create(url); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; ((HttpWebRequest)request).Referer = url; // // write the post data // using (Stream stream = request.GetRequestStream()) { stream.Write(Encoding.UTF8.GetBytes(postdata), 0, Encoding.UTF8.GetByteCount(postdata)); stream.Flush();
-
IE automation questiongleat 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.
-
IE automation questionPete, I appreciate the fact that you have taken the time to respond to my question. If you take a brief moment to read the post you responded to you would note that I am trying to download files from the website of Federal Reserve Bank of St. Louis. While they are a great bunch of folks, I highly doubt that they would put up an ftp server for no other reason than to resolve my little issue:laugh:. If you feel the code is useful, please post a specific example of how it might be used in the context I described. I am open to resolutions of any kind. I have done a fairly extensive search and no one seems to have a solution.
-
IE automation questionThe browser shows the download dialog (save file as...)
-
IE automation questionThanks for your suggestion - I will use any method that works. Simpler = better. I found some examples of using a stream object - I do not understand how to: a) convert the stream to a mshtml document b) post the document back to the server c) handle the subsequent file download.
-
IE automation questionHi Pete I would love to use ftp it would solve so many problems. The question I asked really has nothing to do with ftp. Why is the code you posted relevant? Thanks
-
IE automation questionI need to access a website and download several hundred spreadsheet files. The problem is that I must use POST to initiate the download. I cannot use webclient.downloadfile becuase I dont have a url to pass. I am able to get the download started using a bit of test code I wrote. Now I just need to handle the file download dialog that saves the file. If possible I would like to bypass the download dialog and complete the process in code. The following test code actually works (in its complete form) to get the download started: object missing = ""; InternetExplorerClass ie = new SHDocVw.InternetExplorerClass(); ie.Navigate("http://alfred.stlouisfed.org/series/downloaddata?seid=RSAFS&cid=6", ref missing, ref missing, ref missing, ref missing); System.Threading.Thread.Sleep(5000); mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)ie.Document; foreach (mshtml.IHTMLElement pageElement in doc.all) { // click some elements } Is it possible to get the url that will be sent back to the server from the document AFTER I "click" the parameters? I have already seen The most complete C# Webbrowser control which is posted here on CodeProject. Either it is not designed to do what I described above or I dont understand it well enough to put it to good use. If there is some code there that illustrates what I am asking, kindly point me in the right direction. Thanks anyone for some help with this. I have searched every corner of the internet for an answer and I am truly stumped.