Jul 25, 2008

Parsing

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > VB Programming

free web hosting

Parsing

zachtk8702
Can anyone explain how to parse a webpage using VB.... Ive never done it so im not familiar.

Reply

cached
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)

smile.gif

 

 

 


Reply

NotoriousZach
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?

Reply

NotoriousZach
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......

Reply

magiccode9
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

Reply

joeymuch
theres a parseing routine on planet-source-code.com

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : parsing

  1. Parsing Html As Php
    and XAMPP as the server version on Windows (7)
  2. Parsing .html Pages
    (9)
    This isn't really that urgent but I was wondering, I read somewhere that you can configure you
    server to pars all html pages for php code, and I was wondering if that was true, and if trap17 has
    that feature enabled?....
  3. Xml Parsing In Asp
    (0)
    I've looked everywhere, and for some reason I can't find a decent tutorial on how I can
    download a remotely hosted xml document and parse it in ASP. There are several examples for ASP.NET,
    and a few sites that "looked" like they would have the answers, but I just can't get it to work.
    In many cases I would cut and paste the sample code directly and it would still generate errors.
    From what I understand, I have the XMLDOM because it is included in IE5+, so that shouldn't be
    an issue. It has no problem creating the object, but I still cannot get anything t....
  4. Simple Parsing Functions
    [Delphi] Tutorial (0)
    Because parsing is such an integral part of string manipulation, I took the time to make a quick and
    simple parse function. For you VBers, Delphi is a derivative of Pascal...it's powerful, simple,
    and (best of all) doesn't need external components (eg: ocx files). Hence the code: CODE
    function TForm1.SimpleParse(MainString, BeginString, EndString: string): string;
    var PosBeginString: integer; PosEndString: integer; begin PosBeginString :=
    Pos(BeginString, MainString) + Length(BeginString); PosEndString ....
  5. Parsing A List In A Webpage Help
    Need Webpage Parsing Help (1)
    Hey I want to parse a list in a webpage.......Im not too hot with parsing overall but I figured this
    would be the best place to ask for help..... For example if the HTML was CODE <tr>
    <td>1</td><td><A target="_self" href=#><font
    color=#ff0000>Number1</font></a><td><font face=verdana
    size=2>IDNUMBER1</td> <td><A target="_self" href=#><font
    color=#ff0000>Number2</font></a><td><font face=verdana
    size=2>61506....
  6. [tutorial] Delphi
    Multi-Parsing Function (0)
    I've spent a while trying to create parsing function with Delphi. This language is very useful.
    This tutorial explains how to parse multiple instances of an item in one string. Here is the
    function (which I am actually very proud of): Code: function TForm1.MultiParse(MainString,
    BeginString, EndString: string): TStrings; var PosBeginString, PosEndString, i, LastPos: integer;
    tmpCopy: string; tmpStrings: TStrings; begin tmpStrings := TStringList.Create; LastPos := 0;
    for i := 1 to LastDelimiter(EndString, MainString) do begin PosBeginString := Pos....
  7. Delphi
    Simple Text Parsing Function (1)
    Because parsing is such an integral part of string manipulation, I took the time to make a quick and
    simple parse function. For you VBers, Delphi is a derivative of Pascal...it's powerful, simple,
    and (best of all) doesn't need external component (eg: ocx files). Hence the code: Code:
    function TForm1.SimpleParse(MainString, BeginString, EndString: string): string; var PosBeginString:
    integer; PosEndString: integer; begin PosBeginString := Pos(BeginString, MainString) +
    Length(BeginString); PosEndString := Pos(EndString, MainString); Result := Copy(MainString, ....

    1. Looking for parsing

Searching Video's for parsing
advertisement



Parsing



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE