Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Screen scraping, then caching.... not working on web parts page?

Reply
Thread Tools

Screen scraping, then caching.... not working on web parts page?

 
 
itfetish@gmail.com
Guest
Posts: n/a
 
      06-25-2007
We have a web parts intranet at our office here I have been working
on.

I have been trying to create a way of getting our OCE TDS 600 plotter
queue to be a web part on the page, seeing as their is no way of
interfacing apart from their 'print exec workgroup' web based program.

So I decided to screen scrape, I've done a scrape of the intranet page
of print exec workgroup (http://tds600 on our network) seemed to go
fine, then i used regex, and some replace's to delete the stuff I
didn't want and change some formatting to suit my page then wrote the
html code to a label, seemed to work fine.

I then decided maybe I should do some caching, as this plotter doesnt
want to be hit up when ever user in the network (with autorefresh
every 5 mins) as it is receiving drawings and stuff.

So I tried caching it just for a minute or two, just so that way only
one person hits it every 2 minutes - the rest get it from cache.

But it doesn't seem to be working, I made a test page, seemed to cache
fine, but then when I made it an ascx control and put it on my web
parts page, it never caches. And perhaps as a result, actually
retreiving the scrape is a hit and miss afair, and even worse, people
can't access print exec (which is used to send drawings to plotter) as
it says theres too many users connected (theres no license limit - but
it's obviously a hard limit set so that bandwidth for plots doesnt
suffer - so the web connections must be making lots and overloading
it)

I'm making two parts, 1 to get the status on rolls (empty icons etc)
and one for queue, they are essentiall they same.

Code:
 Sub Page_Load(sender as Object, e as EventArgs)
        Dim RollStatus
        Const strURL As String = "http://tds600/servlet/PEBServlet?
pag=info"


        If Cache.Get("RollState") IsNot Nothing Then
            RollStatus = Cache.Get("RollState")
                Response.Write("retrieved from cache")
            End If

        Else
           response.write ("Regenerating Data")
            Dim PrintExecPage As String
            Dim req As HttpWebRequest = WebRequest.Create(strURL)
            req.Timeout = 1000

            Dim resp As HttpWebResponse = req.GetResponse()

            Dim sr As New StreamReader(resp.GetResponseStream())
            PrintExecPage = sr.ReadToEnd()

            Dim RegEx As New Regex("<table width='100%' border='0'
cellpadding='2' cellspacing='0'><tr>(.*?)Feeder</td>(.*?)</table>",
RegexOptions.None)

            Dim objmatch As Match

            For Each objmatch In RegEx.Matches(PrintExecPage)

               'filter out the ****, store it in RollStatus string


            Next

            If Len(RollStatus) > 20 Then
                Cache.Insert("RollState", RollStatus, Nothing,
DateTime.Now.AddMinutes(3), TimeSpan.Zero)
               response.write ("Cache Written")

            End If

            sr.Close()
            resp.Close()


        End If


        If RollStatus Is Nothing Then
            RollStatus = "Did not load."
        End If


        lblHTMLOutput.Text = RollStatus

    End Sub
whenever the stream actually loads, it tells me its regenerating data,
and that its written to cache, then I hit refresh, and it says the
same thing - no recall from cache.


Any ideas? what have I done wrong? Is it possible our web server is
deleting cache, is there any way to check?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net VB Web Parts - Connections work fine, until I close, then reopen a web part. itfetish@gmail.com ASP .Net 1 05-15-2007 12:50 AM
Serious issue: parts of my page render as not logged in, parts as logged in. Help! pcloches@gmail.com ASP .Net 1 04-12-2007 12:50 AM
Help. SessionID is x then y then x then y BodiKlamph@gmail.com ASP General 0 09-03-2005 03:02 PM
Parts parts....PARTS!!! ARGHHH dstvns A+ Certification 8 01-07-2004 07:57 PM
How come most multi parts dont have all parts? 123 Computer Support 2 09-22-2003 01:55 PM



Advertisments