[C #] [fixed-format webpage parsing] preliminary experience of using regular expressions to process webpages

Source: Internet
Author: User
Parse the webpage with IE WebControl to get specific data in the specific webpage: Set oDocument = Form2.m _ IE. Document
Set oelement = oDocument. Forms ("searchdetail ")

Set oListTableElement = oelement. children (0 ). the advantage of children (0) is that it is simple, but the disadvantage is: how to read the information and what the node value actually means, it is not good to extract the information and put it out as a flexible configuration file. Because it belongs to a Childnodes and a Childnodes traversal, the depth and meaning cannot be set flexibly. I have also experienced a regular expression that specifically processes the HTML of a specific site, because the page I want to process always contains some fixed code. It is found that the following formula can resolve a series of values to one MatchCollection. I used The "The Regulator" tool. The test results are as follows: Collection "hiddentonenames" is always a Collection of XX names in order; Collection "hiddenspnames" is always a Collection of XX names, sort in order, and so on. In C #, you can use the following code to obtain the values of each set: foreach (Match match in matchCollection) {Group groupToneNames = match. groups ["hiddentonenames"]; Group groupSpNames = match. groups ["hiddenspnames"]; Group groupSingers = match. groups ["hiddensingers"];} in this way, I can write special regular expressions for the Portal styles of these schools, but let them output the same Collections names, in this way, the code for getting each field of a ringtone is fixed. You only need to modify the Regular Expression of each school. In addition, I am very grateful to Wang Hui for his wonderful article "Web page crawling practices!

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? PostId = 107090

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.