0

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.

J. Steen
15.6k15 gold badges59 silver badges64 bronze badges
asked Mar 5, 2013 at 10:21
5
  • could you please post an example text? Commented 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/… Commented 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. Commented 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. Commented Mar 5, 2013 at 10:24
  • Any update on this issue? Commented Sep 26, 2014 at 7:52

2 Answers 2

3

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
 }
}
answered Mar 5, 2013 at 10:25
Sign up to request clarification or add additional context in comments.

Comments

1

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.

wp78de
19.2k7 gold badges49 silver badges79 bronze badges
answered Mar 5, 2013 at 10:29

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.