Hi,
This is my first post on this website that was recommended to me by my computing teacher. I have only recently started to learn C# programming and I'm playing around with a project for my mothers business as a letting agent to find properties for her to rent. I find suitable properties by extracting information such as the date of the listing, mobile phone numbers and cost per week.
I have managed to get phone numbers of pages by using the following code with the following URL
http://www.gumtree.com/p/flats-houses/4-bedroom-terraced-student-house-to-rent-in-university-area/1022509215
CODE:
public void GetMobileNumber()
{
//This code will find matches on single webpages and store them in a match collection
string UserURL = textBox1.Text;
WebClient MyWebClient = new WebClient();
//the url in the following line is for testing and must be changeing according to a search variable later!!!!
String HTMLString = MyWebClient.DownloadString(UserURL);
MatchCollection MatchedMobiles = Regex.Matches(HTMLString, "\\s*(.+?)\\s*", RegexOptions.Singleline);
//This code will put the matches into the list defined above
foreach (Match m in MatchedMobiles)
{
string MobileNumber = m.Groups[1].Value;
string FirstTwoNumbers = MobileNumber.Substring(0, 2);
if (FirstTwoNumbers == "07")
{
MobileNumberList.Add(MobileNumber);
}
}
MobileNumberList = MobileNumberList.Distinct().ToList();
ListBoxPhoneNumbers.DataSource = MobileNumberList;
}
I'm struggling to do the same thing but for date added on the following URL:
Any help would be much appreciated,
Many Thanks and Kind Regards
James
Anupam SinghPosted Jun 21, 2014, 12:16 AM
Welcome to C# corner.
Actually you are trying find data from html pages.
An interesting thing about html pages is if you want to display something on page, there are many ways:
1. display direct inside body tag :
your text
2. display data in element
and many more.
In your working code you are retrieving data from
\\s*(.+?)\\s*
which is a span tag. And it might be different in http://www.gumtree.com.
So you have to check rendered html first and then apply your method on it.
Happy Coding :)