I want my program to automatically download only certain information off a website. After finding out that this is nearly impossible I figured it would be best if the program would just download the entire web page and then find the information that I needed inside of a string.
How can I find certain words/numbers after specific words? The word before the number I want to have is always the same. The number varies and that is the number I need in my program.
-
could you please post an example text?BergListe– BergListe2013年03月05日 10:23:54 +00:00Commented Mar 5, 2013 at 10:23
-
first you need to make sure, the word is unique and then you can use msdn.microsoft.com/de-de/library/…Vogel612– Vogel6122013年03月05日 10:24:09 +00:00Commented Mar 5, 2013 at 10:24
-
I have edited your question for clarity and used phrases more known to the community. If any of my changes were incorrect, please make edits yourself to clarify your question.J. Steen– J. Steen2013年03月05日 10:24:18 +00:00Commented Mar 5, 2013 at 10:24
-
Your question's a bit too vague. Provide more context and some example code if you can. 'Downloading certain information off a website' is not necessarily impossible depending on the details of it. Look into screen scraping.user1017882– user10178822013年03月05日 10:24:38 +00:00Commented Mar 5, 2013 at 10:24
-
Any update on this issue?Joel Peltonen– Joel Peltonen2014年09月26日 07:52:46 +00:00Commented Sep 26, 2014 at 7:52
2 Answers 2
Sounds like screen scraping. I recommend using CSQuery https://github.com/jamietre/CsQuery (or HtmlAgilityPack if you want). Get the source, parse as object, loop over all text nodes and do your string comparison there. The actual way of doing this varies a LOT on how the source HTML is done.
Maby something like this untested example written from memory (CSQuery)
var dom = CQ.Create(stringWithHtml);
dom["*"].Each((i, e) =>
{
// handle only text nodes
if (e.NodeType == NodeType.TEXT_NODE) {
// do your check here
}
}
Comments
I've used HTML Agility Pack for multiple applications and it works well. Lots of options too.
It's a lovely HTML parser that is commonly recommended for this. It will take malformed HTML and massage it into XHTML and then a traversable DOM, like the XML classes. So, is very useful for the code you find in the wild.