Iamlaosong
To use a program to grab data from a Web page, you need to familiarize yourself with the HTML and JavaScript languages, and here's a routine that creates a JSON object in JavaScript, learns and grasps its content, makes a note of the routine here, records what I know, and prepares it for future verification.
The program is simple and divided into three parts:
1. display the title with large characters;
2, <p> part: Show the structure of a piece of information, but no content, the content is added later;
3, <scrip> part:JavaScript program, first defines a JSON structure of the variable jsonobject, and then, with the contents of the variable to fill in the <p> section, the positioning method is defined by the ID, Here is a detailed explanation:
Statement document.getElementById ("Jname"). Innerhtml=jsonobject.name is to find the element with ID jname, replace the content with Jsonobject.name, the content of this variable is Bill Gates, which is:
Change <span id= "Jname" ></span> to <span id= "Jname" >bill gates</span>
When we use the program to capture data from the Web page, we often need to fill in the form, but also in this way to modify the content of the page, finally submitted, to get what we need, for example, the following statement is to fill in the email number and submit the query:
WebBrowser1.Document.GetElementById ("Mailnum"). InnerText = "1126381490399"
WebBrowser1.Document.Forms ("Mailtracksnglform"). Submit
You can also use the following notation:
WebBrowser1.document.Forms ("Mailtracksnglform"). All ("Mailnum"). Value ="1126381490399"
For example, after completing the user name and password, submit:
WebBrowser 1.document.forms (0). All ("name"). Value = "AHSD08"
WebBrowser 1.document.forms (0). All ("password"). Value = "song0829"
WebBrowser 1.document.forms (0). Submit
corresponding to the elements of the page or object positioning, you can use the ID name, you can also use the serial number, such as the above example of Forms (0).
The following is the example code for the analysis above:
The following results are performed:Create a JSON object in JavascriptAuthor: iamlaosong
Name: Bill Gates
Age:
Address: Fifth Avenue New York 666
Phone: 555 1234567
Creating JSON objects in JavaScript--routine parsing