|
If you have many different combinations to cater for, then patterns and regular expressions may also help. I think I have once used regular expressions for similar problem in the past...
Ashvin Gunga
|
|
|
|
|
20 Feb 2007
I want to gather data from this page:
http://moneycentral.msn.com/investor/StockRating/srstopstocksresults.aspx?Score=10
and process it in C#.
The problem is the page content is loaded via scripts (I think) and the page's .html source does not contain the data. So my initial idea of getting and processing the page's .html source won't work.
Manually typing Control-A Control-C and pasting into a text document would work, but I'd prefer an automated solution.
A. Is there an easy way to actually handle the scripts from within C# (or .NET in general)?
OR
B. I've never done control of another program through C#, although I understand that .NET allows this. Can my browser be controlled to send me the text or save it to a file?
OR
C. Perhaps a FireFox plug-in should be written? (I've never written a plug-in before, either.)
Suggestions would be appreciated.
Thanks,
Mark
|
|
|
|
|
Try System.Net.Webrequest .. to create a request for the page, and if you're not sure of a correct response, use WebResponse.GetResponseStream() to process the response
Patt
|
|
|
|
|
Thanks for the try, but this just retrieves the general page setup and the scripts themselves... none of the data that is displayed on the page is in what is obtained. (I do really appreciate the pointer to these functions, however. I need them for another project I have in mind!)
Still looking for a solution.
Mark
|
|
|
|
|
Maybe you can be a little more specific about the "data" you are looking for. I'm assuming you need the items displayed in the 6 column result table on the page ?
Patt
|
|
|
|
|
Sounds like it uses AJAX to retrieve the data?
Maybe you could see what URL is being called by the script from the page source?
|
|
|
|
|
The information that I want is the large table of Stock related information.
I tried looking at links in the .html source, and the one that I suspect provides the content gave an "invalid" reply from a database. Perusing the scripts (which I do not know how to read) it appears the script and the database may exchange some password-like information before allowing the query.
Still looking for a way to capture the text that the Web browser has already obtained, without doing a manual copy and paste to a text file.
Mark
|
|
|
|
|
Hi guys, I have a form that contains 6 Combo boxes and i want to bind them to database, I want to creat a function like this :
void FillIn(string Tbl, string Fld)<br />
{<br />
ComboBoxCBDS.Clear();<br />
ComboBoxCBDA.SelectCommand = new SqlCommand("Select * from " + <br />
Tbl + " Order By " + Fld, ItemsConn);<br />
ComboBoxCBDA.Fill(ComboBoxCBDS, Tbl);<br />
NameOfCB.DataSource = ComboBoxCBDS.Tables[Tbl];<br />
NameOfCB.DisplayMember = Fld;<br />
NameOfCB.ValueMember = Fld;<br />
}
The Problem is "NameOfCB" !!! how can I bring the name of the ComboBox in my function I tried string variable but it didn't work !
Thanx !
-- modified at 5:24 Tuesday 20th February, 2007
|
|
|
|
|
Why not pass in the ComboBox itself.?
void FillIn(string Tbl, string Fld, ComboBox comboBox)
{
ComboBoxCBDS.Clear();
ComboBoxCBDA.SelectCommand = new SqlCommand("Select * from " + Tbl + " Order By " + Fld, ItemsConn);
ComboBoxCBDA.Fill(ComboBoxCBDS, Tbl);
comboBox.DataSource = ComboBoxCBDS.Tables[Tbl];
comboBox.DisplayMember = Fld;
comboBox.ValueMember = Fld;
}
By the way, you should use parameterized queries instead of concatenating the query string. Take a look at this article here on CP: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
I have a form where I want to popup a small form (messagebox) where the user enters a value into a textbox on that popup form and that value is returned to the main form for processing.
I know how to write the code to do this with a showdialog etc but was wondering if anyone has come accross a control that can do this "out of the box" so to speak.
I would have thought the messagebox control could be used as a base for such a control but have no idea how to go about it.
Any suggestions.
Glen Harvy
|
|
|
|
|
No, you need to write a control to do this. The messagebox is not a suitable base, just create a new form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thought that might be the case.
Glen Harvy
|
|
|
|
|
i just answered a question similar to this.
if i've missunderstood u're question then forgive me.
the answer is:
declare a static variable :
public static int n;
and access, modify or whatever from form2 as: Form1.n =5;
hope this helps.
|
|
|
|
|
Yes, you've misunderstood. He wants to use a MessageBox as the base for his form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for that - I'll work on it now.
I've never understood/used static so it's time I did
-- modified at 7:43 Tuesday 20th February, 2007
Geez that was easy - Thanks heaps
Glen Harvy
|
|
|
|
|
datetime n = form1.n;
-- Not Working : error on 'n'.
'System.Windows.Forms.Form' does not contain a definition for 'n'.
just have to define a variable 'int n' in form1, n try to access it in form2.
how?
nekshan.
|
|
|
|
|
if you only need to pass the value of the variable 'n' to form2 then just pass the variable as an argument of the form2 constructor
eg. Form2 frm= new Form2(n);
if that value need to be modified and updated in form1 you could declare it as static
eg. public static int n;
and modify it in form2 as: Form1.n=5;
hope this helps.
|
|
|
|
|
The obvious way is to pass it in, as someone said. The drawback of using statics is, it means you can only have one instance of that form. The best way to communicate from form2 back to form1 is a delegate.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
why a delegate? why not a property?
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
V. wrote: why a delegate? why not a property?
Loose coupling - So the forms don't have to know about each other.
|
|
|
|
|
As well as loose coupling, a delegate will allow a value to be sent between forms that are both active ( if form2 is modeless and form1 needs to update itself right away )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
' define
public int n
'on top of page in form1
|
|
|
|
|
bad idea, it's against incapsulation rules. You should use a property for that
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
And make the property read only, or you break encapsulation just the same
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I tend to disagree.
Suppose I have a variable distance (integer)
A distance can never be smaller then 0.
If I make my variable public, you can set it to what integer you like even < 0.
With a property you could build in a check.
set{<br />
if(value >= 0){<br />
distance = value;<br />
}<br />
else{<br />
distance = 0;<br />
}<br />
}
|
|
|
|