|
|
|
|
![]() ![]() |
Feb 6 2005, 11:54 PM
Post
#1
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 81 Joined: 3-August 04 Member No.: 609 |
Can anyone explain how to parse a webpage using VB.... Ive never done it so im not familiar.
|
|
|
|
Mar 1 2005, 03:05 PM
Post
#2
|
|
|
Newbie ![]() Group: Members Posts: 3 Joined: 1-March 05 Member No.: 4,071 |
It's quite simple, really. All you need is an INET control (called INET1 for the sake of not repeatedly calling it an INET control) and a textbox named txtparsethis (same reason as inet1)
First make sure that the textbox is multiline. To get the page source into the textbox, do txtparsethis.text = Inet1.OpenURL("http://theweburlgoeshere.blah/blah/blah.blah") Lets say that you are parsing the amount of points someone has here on this site. After making sure you are logged in, get the source, which is at http://www.trap17.com/forums. Then after looking at the source, look at the thing that preceeds the points you have and is after the points you have. let strone = preceding and strtwo being the thing after it, do startlook = instr(1, txtparsethis.text, strone) + len(strone) endlook = instr(startlook,txtparsethis.text,strtwo) pointsstr = mid(txtparsethis,startlook,endlook) points = val(pointsstr) |
|
|
|
Mar 2 2005, 03:46 AM
Post
#3
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 55 Joined: 26-February 05 Member No.: 3,996 |
could you just change text1.text to something like Source for the sake of not having to put a textbox on the webpage or will that mess things up?
|
|
|
|
Mar 2 2005, 03:55 AM
Post
#4
|
|
|
Member [Level 1] ![]() ![]() ![]() ![]() Group: Members Posts: 55 Joined: 26-February 05 Member No.: 3,996 |
Hey I figured that out, now Ihave 2 questions....... Say when im looking in the source and there is a space (like they hit enter twice) then more stuff that I need to add to the after part so it is specific enough....... How would I go about making it not read the blank lines......
Also, how would I parse a certain vertical field in a table like. <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] <TD></TD> <TD></TD></TR><Tr> [ FIELD 1] [ FIELD 2] Something like that for instance, how would I parse the entire FIELD 1...... |
|
|
|
Nov 2 2005, 08:44 AM
Post
#5
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 162 Joined: 1-November 05 From: SATA II Member No.: 13,683 |
hi, NotoriousZach
if iam not wrong, you wanted to replace the extra space and enter key char, if so, you can use the replace and instr function to do that. CODE do while(something check or value that be true) do while(something check) pos = instr("space to find") // this will find the first char that is space char (then) call a function to check if following is also space, if so, go on to check the next unlti that is false(not the space char) if("function return value") = "some value" then // you can have the value return as object, so you can check state & position value startpos = startpos + 1 exit do elseif(("function return other value") = "some other value" then replace the found space char("will more than 1") to single space char statrtpos = new pos end if loop here, you should have a set of variable that hold space char start and end pos. it can then be safe to use replace function to override that with a single space char or other that you easy to maintain hereafter( for building parsing tree ). loop - hope this help - Eric |
|
|
|
Nov 25 2005, 06:43 PM
Post
#6
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 20 Joined: 25-November 05 Member No.: 14,896 |
theres a parseing routine on planet-source-code.com
|
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 5th September 2008 - 01:06 PM |