Hi guys..
I would like to get some results from a website that has a search box and a button, how could i do that?
It's a news articles website in PHP and i would like to search for a value and get the titles back and use them in my c# windows application.
there are no parameters and values in the address of the website.
i have tried some things but i really don't know how to do it..
let me just mention that i am doing it for my personal use and i only want to search for one value one time a week but in an automated way and in that way when I'll have the results that i am interested of i would make my app send me an e-mail.
so far what i got from the website is this:
<form method="post" action="findnews.php">
<input align="left" size="32" name="search"/>
<input type="submit" value="new search" style="width: 80px;"/>
</form>
how could i put my own value for the search and get the results as text or something?
I am kind of a Newbie as for web coding..
I will appreciate any help..
Thank you!
Roy.
Revision:
Thanks to Abishek's advice i got someting going..
though it still seems as i have a problem.
meanwhile i am getting the source code for the page itself and not the results.
the problem may be in this line:
myWebClient.Headers.Add("search", "application/x-www-form-urlencoded");
I have tried to define this line to handle the search box on the page but i am not sure if this is the correct place to do it..
I am not really sure how to configure this line and couldn't find any material on MS sites for figuring it out..
the question now is: How do i make use of the search box?
I will appreciate if you'll have a look..
This is my C# win application..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace WinFindNews
{
public partial class Form1 : Form
{
public WebHeaderCollection Headers { get; set; }
public Form1()
{
InitializeComponent();
string uriString;
uriString = "http://thedomain.com/findnews.php";
WebClient myWebClient = new WebClient();
string postData = "test query";
myWebClient.Headers.Add("search", "application/x-www-form-urlencoded");
richTextBox1.AppendText("Resulting Request Headers: ");
richTextBox1.AppendText(myWebClient.Headers.ToString());
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
byte[] responseArray = myWebClient.UploadData(uriString, "POST", byteArray);
richTextBox1.AppendText(Encoding.ASCII.GetString(responseArray));
}
}
}
Thank you!!!
Roy.