G
Guest
I have to do some screen scraping and I need to do it for more than 1 site.
I am making a call to WebRequest.Create(url) (to many urls) and I wanted to
put the urls, and the text that I use for the Regular expression in the
config file. But if the name is "site1" and the url is
"www.somesitewithalongurl.com" and the text I'm looking for is
"<title>sometitletext</title>", how can I use all 3 in the config file.
If I have the following in the config file,
<appSettings>
<add key="Site1" value="http://www.somesite with a long url.com"/>
<add key="Site2" value="http://www.another long url.com"/>
</appSettings>
and the following for screen scraping,
Urls = ConfigurationSettings.AppSettings["Site1"];
regex = new Regex(mytitletaginfo ,RegexOptions.IgnoreCase);
how can I add a 3rd attribute to the "add" xml tag, and how do I access it?
I'm thinking something like
<add key="Site1" value="http://www.somesitewithalongurl.com"/
value2="<title>sometitletext</title>">
But how do I access the value2 attribute using the ConfigurationSettings
static class.
Also if I add another site, I would rather not code it so I have to know
what the "key" attribute value is, so how do I iterate or loop over the
"add" xml tags and retrieve all 3 values, namely key, value, and value2.
Ultimately, I will be adding more urls and its associated <title> tags to
the app.config file and I can't go back to the code and recompile for new
urls.
Any help or links to articles discussing this will be greatly appreciated.
Thanks
gv
I am making a call to WebRequest.Create(url) (to many urls) and I wanted to
put the urls, and the text that I use for the Regular expression in the
config file. But if the name is "site1" and the url is
"www.somesitewithalongurl.com" and the text I'm looking for is
"<title>sometitletext</title>", how can I use all 3 in the config file.
If I have the following in the config file,
<appSettings>
<add key="Site1" value="http://www.somesite with a long url.com"/>
<add key="Site2" value="http://www.another long url.com"/>
</appSettings>
and the following for screen scraping,
Urls = ConfigurationSettings.AppSettings["Site1"];
regex = new Regex(mytitletaginfo ,RegexOptions.IgnoreCase);
how can I add a 3rd attribute to the "add" xml tag, and how do I access it?
I'm thinking something like
<add key="Site1" value="http://www.somesitewithalongurl.com"/
value2="<title>sometitletext</title>">
But how do I access the value2 attribute using the ConfigurationSettings
static class.
Also if I add another site, I would rather not code it so I have to know
what the "key" attribute value is, so how do I iterate or loop over the
"add" xml tags and retrieve all 3 values, namely key, value, and value2.
Ultimately, I will be adding more urls and its associated <title> tags to
the app.config file and I can't go back to the code and recompile for new
urls.
Any help or links to articles discussing this will be greatly appreciated.
Thanks
gv