I would like my program to be able to access a website that processes string input and returns some information about it. I want to input two sequences, submit them and read the result through the program. The website is the following:
http://scansite.mit.edu/motifscan_seq.phtml
If you enter say 5031601 as Protein Name and DRNAYVWTLKGRTWKPTLVILRI as Sequence, you will be redirected to the results site. This is the site I want to be able to read with my program. I have researched a lot about this but I can't seem to get any useful solution.
Can anyone please help me out?
EDIT:
I tried to create a web request with the following code (adapted from the link):
WebRequest request = WebRequest.Create(
"http://scansite.mit.edu/motifscan_seq");
request.Method = "POST";
string postData = @"motif_option=all&protein_id=5031601&
sequence=DRNAYVWTLKGRTWKPTLVILRI&
stringency=High&submit=Submit Request";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
using (WebResponse response = request.GetResponse())
using (Stream resSteam = response.GetResponseStream())
using (StreamReader sr = new StreamReader(resSteam))
File.WriteAllText("SearchResults.html", sr.ReadToEnd());
System.Diagnostics.Process.Start("SearchResults.html");
When I open the SearchResults.html, it contains the original form site with the protein name entered. The sequence hasn't been entered (it is a textarea, not a textbox). And it hasn't been submitted. Is there anything I'm missing or doing wrong?
Resolved the issue by sending the request to the uri that is stated in the action attribute of the form tag (http://scansite.mit.edu/cgi-bin/motifscan_seq).