| | |
hot to get html from url requiring login
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 9
Reputation:
Solved Threads: 0
hi
i need to read html from a url requiring that i log in to the site.
how is that done? i think it depends on how the site is build?
its for a torrent site, and they often use the same template as far as i know.
the site im trying to read through c# is http://nordic-t.org/browse.php
this code works fine for getting any page, that doesnt require login:
how do i merge username and password into all this?
i searched, but didnt find anything for doing it with a page using php. maybe i searched for the wrong things.. still kinda newbie with programming
i need to read html from a url requiring that i log in to the site.
how is that done? i think it depends on how the site is build?
its for a torrent site, and they often use the same template as far as i know.
the site im trying to read through c# is http://nordic-t.org/browse.php
this code works fine for getting any page, that doesnt require login:
C# Syntax (Toggle Plain Text)
// Address of URL string URL = textBox1.Text; try { // Get HTML data WebClient client = new WebClient(); Stream data = client.OpenRead(URL); StreamReader reader = new StreamReader(data); string str = ""; str = reader.ReadLine(); while (str != null) { richTextBox1.AppendText(str); str = reader.ReadLine(); } data.Close(); } catch (WebException exp) { MessageBox.Show(exp.Message, "Exception"); }
how do i merge username and password into all this?
i searched, but didnt find anything for doing it with a page using php. maybe i searched for the wrong things.. still kinda newbie with programming
Without even bothering to question you about your motives, I shall get right to it:
The measures you will need to take may vary from site to site, and I for one do not know which methods this site uses to verify users. But it is important to note that it is quite possible that you can't access the "normal" page without logging in, or at least convincing the server that you have. This is because the server probably doesn't bother to send you the normal page (and it shouldn't) until you are verified as a user.
I would suggest that before running the script on that page, you use the web client to log in to the site. This will set any variables that the server may use to log/verify your authentication.
Next, if that web client you are using supports cookies, I would suggest turning them on. If it doesn't, get one that does. Whenever the server asks to write to a cookie, let it. Whenever it asks for the data in a cookie it wrote to, let it (don't let it read cookies it didn't write unless your web client is encapsulated, essentially meaning separated from IE, Firefox or whatever browsers you use). The reasons cookies are important, is that many sites use them to help handle user log ins (including the ones I get to work on)
Good luck.
The measures you will need to take may vary from site to site, and I for one do not know which methods this site uses to verify users. But it is important to note that it is quite possible that you can't access the "normal" page without logging in, or at least convincing the server that you have. This is because the server probably doesn't bother to send you the normal page (and it shouldn't) until you are verified as a user.
I would suggest that before running the script on that page, you use the web client to log in to the site. This will set any variables that the server may use to log/verify your authentication.
Next, if that web client you are using supports cookies, I would suggest turning them on. If it doesn't, get one that does. Whenever the server asks to write to a cookie, let it. Whenever it asks for the data in a cookie it wrote to, let it (don't let it read cookies it didn't write unless your web client is encapsulated, essentially meaning separated from IE, Firefox or whatever browsers you use). The reasons cookies are important, is that many sites use them to help handle user log ins (including the ones I get to work on)
Good luck.
![]() |
Other Threads in the C# Forum
- Previous Thread: non english help creating for c# application
- Next Thread: Rows not inserting
| Thread Tools | Search this Thread |
.net access algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






