|
Hi, I want to extract data from an HTML Web Page, which .Net Framework classes I should use to perform that?
|
|
|
|
|
What exactly are you extracting? You might find Regex[^]es to be useful for parsing purposes.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
if you want the html code from a page you must do this:
<br />
using System;<br />
using System.Net;<br />
using System.Text;<br />
using System.IO;<br />
<br />
<br />
public class Test<br />
{<br />
public static void Main (string[] args)<br />
{<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (@"http://www.site.com");<br />
<br />
request.MaximumAutomaticRedirections = 4;<br />
request.MaximumResponseHeadersLength = 4;<br />
request.Credentials = CredentialCache.DefaultCredentials;<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();<br />
<br />
Console.WriteLine ("Content length is {0}", response.ContentLength);<br />
Console.WriteLine ("Content type is {0}", response.ContentType);<br />
<br />
Stream receiveStream = response.GetResponseStream ();<br />
<br />
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);<br />
<br />
StreamWriter w = new StreamWriter("ciao.txt");<br />
w.WriteLine(readStream.ReadToEnd());<br />
<br />
Console.WriteLine ("Response stream received.");<br />
Console.WriteLine (readStream.ReadToEnd ());<br />
response.Close ();<br />
readStream.Close ();<br />
Console.ReadLine();<br />
}<br />
}<br />
i hope this it was you wanted
|
|
|
|
|
If you're only going to be extracting a small range of data from the page, I'd recommend using regular expressions. Otherwise, you should probably use SGMLReader[^].
|
|
|
|
|
Hi, Ive posted on this board before but in the Visual C++ area.
My Question is :
In my previous questions, I created a new EditBox Class Called CInitials
and changed the OnChar Message to append a '.' after each keypress.
The code for that was done like this:
<br />
void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
{<br />
if (isalpha(nChar) )<br />
{<br />
if ( islower(nCHAR) )<br />
nChar -=32;<br />
<br />
DefWindowProc(WM_CHAR, nChar,<br />
MAKELONG(nRepCnt, nFlags));<br />
<br />
nChar = '.';<br />
DefWindowProc(WM_CHAR, nChar,<br />
MAKELONG(nRepCnt, nFlags));<br />
}<br />
<br />
if ( nChar == VK_BACK )<br />
{<br />
CEdit::OnChar(nChar,nRepCnt,nFlags);<br />
CEdit::OnChar(nChar,nRepCnt,nFlags);<br />
}<br />
}<br />
The CInitials Class was derived from the CEdit Class in Visual C++.
The question is, can this be done in C#? If yes how?
Thanks again
Tom
|
|
|
|
|
Pretty much the same way, but instead of the VK enum, you have the Keys enum, so Keys.BackSpace or something like that. The messages are the same ( seeing as it's still a window underneath it all ).
Stuff like IsLower is in the Char space, so Char.IsLower(myChar)
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Christian,
How do you edit OnChar Messages in a C# EditBox?
Tom
|
|
|
|
|
There's either an OnChar or an OnKeypress, just type public override, and the ide will give you a list to choose from.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi there
I need to ask something really urgently. I need to be able to send a file over the serial port to a PIC programmer. how do i go about doing that?
I have simple serial communication working at the moment. I am using C#. the only thing with that is that if i send a 'p' i get back the hexadecimal value of 'p' instead of getting the character so how can i do that?
i am using an already created class for my serial comm in dotnet 1.1.
another thing is that i want to xor the file or perform simple encryprion on the file so how do i go about doing that? I am using windows forms in this case so am not sure how to xor a file or perform simple encryption on a file.
Pleas help me urgently.
thanks
|
|
|
|
|
you can use c# functions to convert hex value to char or byte to char,you must change output format of receive function in your serial component.
|
|
|
|
|
hi there
I am using SQL server and windows forms in C#. i have created a database using the tables and query. Now if i update the database manually, it works. what i would like to know is that i will be getting data over the serial port that will put into the databases. will it be possible to get the databases automatically updated? If yes, then how can i go about doing that?
Thanks in advance
|
|
|
|
|
Atmadarshini wrote: i will be getting data over the serial port that will put into the databases. will it be possible to get the databases automatically updated? If yes, then how can i go about doing that?
Your question was somewhat vague about what the actual problem is:
Do you need to know how to read the data from the serial port?
Do you have the data from the serial port but need to know how to interpret the data?
Do you want the database server to read the data coming from the serial port and it will update itself?
There is no automatic process to do any of the above, you will have to write some code to read the data from the serial port. You are going to have to interpret the data. If your application can do that then it can form the required commands to update the database.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Hi there
I have created a checklist form. in my checklist form, i have checkboxes and what i want to do is that when i tick on the checkboxes, i have a button that says generate report so when i click on this button, what happens is that another form pops up that contains labels related to the checkboxes wih messages. I manage to get to that part now the problem is that if i want to save them in a file or so, how do i do that so that i can have proof. the thing is that if i dont save them, the next time there will be different checkboxes ticked so i need to save them.
i was reading through the msdn library and i only came across how to save pictures and save text in a rich textbox but i need to if possible be able to generate a report kind of thing. How do i do that?
One last thing is that, is it possible to automate the checklist form in the sense that instead of me ticking the checkboxes, when something happens, the checkboxes are ticked on their own? how would io go about doing that as well?
I hope that i am explaining things properly.
All help will be highly appreciated.
Thanks in advance
|
|
|
|
|
Atmadarshini wrote: I manage to get to that part now the problem is that if i want to save them in a file or so, how do i do that so that i can have proof.
What sort of file ? Text, a graphic, or what ? Writing a text file in C# should be pretty easy to find info on with google.
Or do you mean you want to save info on what boxes were checked for use by your program ? If so, you can save the data as text, xml or in the registry.
Atmadarshini wrote: but i need to if possible be able to generate a report kind of thing.
A graphic report, or just text ?
Atmadarshini wrote: One last thing is that, is it possible to automate the checklist form in the sense that instead of me ticking the checkboxes, when something happens, the checkboxes are ticked on their own?
You can write code to iterate through the checkboxes and check them, or check specific ones.
Atmadarshini wrote: I hope that i am explaining things properly.
To be honest, I found your questions vague, please try to clarify, and I will elucidate further.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Sorry if I am showing my ignorance - but how in C# do I easily determine the directory containing my executable? When executed via a File Association the Home Directory is that containing the file. Brad Bruce has supplied a C++ version (search articles for Program Directory), but I would like a C# version. Ta - Graham.
Pensioner Graham Dean
|
|
|
|
|
Sorry - found it further down in this forum:
Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "filename");
RTFM Graham!
Pensioner Graham Dean
|
|
|
|
|
i've crypted a file.
Then embedded in another application.
I want to open in MemoryStream the embedded crypted file, then decrypt it.
What i'm asking is, can i do it using only MemoryStream Files without transferring something on the Hard Disk?
Can i make write operations on MemoryStream files and just to use the new output before to close it? That is if i use FileStream i get all the write operations ended when i close the object, is it the same for MemoryStrem?
|
|
|
|
|
|
Here is a user define message in vc++ 6.0 dll, such as WM_USER.
How to delegate the event in C#?
|
|
|
|
|
Hi All,
I want to know how to implement push server architecture using .Net (C#).
|
|
|
|
|
Depends on what you wanna push...
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
I have a distributed client-server application and I want to add all my Binaries and Dlls on the server machine and in case of updating any file server machine will push this updates to clients machine,
i hope you can help me
|
|
|
|
|
Look at the MS Application Updater block.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
what do u mean by MS application updater and where can i find it
|
|
|
|
|
Google is your friend...
Click here[^]
|
|
|
|
|