Results 1 to 4 of 4

Thread: My First APP (PageScanner) - Where to Begin?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    12

    Smile My First APP (PageScanner) - Where to Begin?

    Hi.

    Im a long-time web builder who has wanted to begin to learn VB, but hasjust decided to begin programming because I now have a reason. And would like just a wee bit of advice, so that I can at least start in the right direction.

    I would like to begin my programming journey by building a small app that grabs my game clubs scores and stats from off of a website.

    To be more clear...

    I am part of an online game club who plays online games on Yahoo'c gaming site. We can click on a link that takes us to a page that shows the detailed scores and stats of games we have played. We then manually enter these scores and stats back into our gaming club's database.

    Now, I would like to build a small app that would:
    1. Go to my "YAHOO GAMES SCORES & STATS" page.
    2. Copy the Scores and stats of (specified) games
    3. Paste the scores and stats into a file (text, Excel, etc...), OR EMAIL them in a formatted way.

    My question is - where should I begin, what should I read? I Own VB 6 and VB.Net.


    Thank you.

    -Kaan-

  2. #2
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    Well this is a ASP.Net solution but I think you could make it work for what you are trying to do. All I am doing is Screen Scraping from the Yahoo site. Keep in mind two things. 1) I am not sure whether Screen Scraping is legal or not without permission and 2) It probably will not work on a site where authentications is needed.

    First check out this site from Yahoo.
    http://classifieds.yahoo.com/

    Lets say that you just wanted to grab the section of the page that shows the catagories only. You could use the code below to do so:
    VB Code:
    1. <%@ Page Language="VB" %>
    2. <%@ import Namespace="System.IO" %>
    3. <%@ import Namespace="System.Net" %>
    4. <script runat="server">
    5.  
    6.     Sub Page_Load
    7.         Dim strmReader as StreamReader = Nothing
    8.         Dim StrURL as String = "http://classifieds.yahoo.com/"
    9.         Dim objRequest as WebRequest = WebRequest.Create(strUrl)
    10.         Dim objResponse as WebResponse = objRequest.GetResponse()
    11.  
    12.         strmReader = New StreamReader(objResponse.GetResponseStream())
    13.  
    14.         Dim strContent as String = strmreader.ReadToEnd()
    15.         Dim RegEx as Regex = _
    16.             New Regex _
    17.             ("<!-- BODY:END:MAIN:TOP -->((.|\n)*?)<!-- - end FOOT ad call --->", _
    18.             RegexOptions.IgnoreCase)
    19.  
    20.         Dim getMatch as Match = RegEx.Match(strContent)
    21.  
    22.         lblbody.Text = (getMatch.Value)
    23.  
    24.     End Sub
    25.  
    26. </script>
    27. <html>
    28. <head>
    29. </head>
    30. <body>
    31.     <asp:Label id="lblBody" runat="server"></asp:Label>
    32. </body>
    33. </html>
    If you cut and paste this code as is and then browse to it you will get a screen like this (attached).

    In the sample above everything is being sent to a lable but there is nothing that would stop you from putting the information into a email or a file. By the way you set the content you want to scrape with the RexEx. In the sample above it starts with <!-- BODY:END:MAIN:TOP --> and ends with <!-- - end FOOT ad call --->. If you look at the source of the original page you will see those comments in the html.
    Attached Images Attached Images  

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2004
    Posts
    12
    Thanks, Buk! This looks very promising!

    This may be a dumb question, but just so I understand -

    The page that you're showing me in the jpg is is beeing stored in the "LABEL" of the ASP code? What's the purpose of the "label"?

    How would the info be extracted to a file?

    Thanks.

    -Kaan-

  4. #4
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    Well the label was just to show you that you could take partial content of a web page store it in a string and then pass it to the browser through the label. You could just as easily send the string in the body of an email or write it to a file.

    As far as writing it to a file you are going to have to get that info from someone else because I have never done so. Although I don't think it should be all that hard.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width