Solved

How to create a ASP Web Scraping Application

Posted on 2009-06-28
15
1,296 Views
Last Modified: 2012-06-27
Hello everyone. I am attempting to create a web based application that will mine a website for data to store in a database. I have successfully scraped the web page of my target. The problem is that the first page is a log in page. How can i interact with the scraped page to force it to log in and then go into the data mining procedure. Any and all advice will be greatly appreciated.....
0
Comment
Question by:MatrixUnleashed
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:lharrispv
ID: 24737562
How are you doing the scraping?  Are you sending an HTTP request?  If so can you put the log in information in the body of the request?
0
 

Author Comment

by:MatrixUnleashed
ID: 24739716
Yeah i have been reading about the HTTP request but im not sure if that would help me. I want to create a application where at midnight every night it performs a scape of data on the target website. The problem is: In VB i can use a web browser control and input the necessary data into the log in page and invoke a button click to log me in. But the data is spread through multiple pages. From what i have read the scape gives you a hard copy of the information on that one page. I haven't come across a way to interact with the page after it has been scraped.

VB would do what i need but i need this to be available over the internet for multiple people to access.

Detailed information:
I am using a third party web application to track what work my technicians have completed. I need to scrape the data so that I can score them, generate reports, and payroll

Page 1: Log In Page
Page 2: List of Technician's work in a combo box
Page 3: Select job details which are spread out in multiple combo boxes

I hope this help explain what i looking to do. I not looking for the answer but path to the answer. Not afraid of research just want to research the right thing. lol

Thanks
0
 

Author Comment

by:MatrixUnleashed
ID: 24739760
Also its a https:// site
0
 
LVL 8

Accepted Solution

by:
lharrispv earned 500 total points
ID: 24739910
Personally I would use the HTTP Request.  I think it will be the easiest way to go.  You should be able to Post a request buidling out the body and headers as needed.  The response will contain the text of the page and you can parse out the results into an excel spread sheet, email, report etc.

You can always use Windows Task Scheduler to call the at midnight or whatever the Unix equiv is.
0
 

Author Comment

by:MatrixUnleashed
ID: 24740294
Using the HTTP Request will allow you to invoke click member functions and go to other pages? If so do you know where I can find a tutorial on HTTPRequest. I have been searching Google but haven't found a good tutorial....
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24740345
Well yes and no.. you cannot actually click with it.  Keep in mind that clicking on a link or a form is nothing more then a post being sent.  That means a HTTP request.. so if you know what page you would be going to after you click you can post tot hat page with the informationt hat would be sent after the click.

Try googling it.  There is TONS out there.  That is what I have been doing.  http request scrape content
0
 

Author Comment

by:MatrixUnleashed
ID: 24740580
Im going through all of them but none are starting from the beginning... For those of us who knows nothing of HTTP request.... Any suggestions???
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 8

Expert Comment

by:lharrispv
ID: 24740688
0
 

Author Comment

by:MatrixUnleashed
ID: 24740788
I dont think the http request works for https sites.... I included a sample i found. I ran it will the sample site then tried mines.
Original Code:    
 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try

            Dim fr As System.Net.HttpWebRequest

            Dim targetURI As New Uri("http://weblogs.asp.net/farazshahkhan")

            fr = DirectCast(System.Net.HttpWebRequest.Create(targetURI), System.Net.HttpWebRequest)

            'In the above code http://weblogs.asp.net/farazshahkhan is used as an example

            'it can be a different domain with a different filename and extension

            If (fr.GetResponse().ContentLength > 0) Then

                Dim str As New System.IO.StreamReader(fr.GetResponse().GetResponseStream())

                Response.Write(str.ReadToEnd())

                str.Close()

            End If

        Catch ex As System.Net.WebException

            Response.Write("File does not exist.")

        End Try

    End Sub
 
 
 
 
 
 
 
 

Changed Code:

    

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try

            Dim fr As System.Net.HttpWebRequest

            Dim targetURI As New Uri("https://technet.csgsystems.com/hou1/tn/technet.htm?Id=1")

            fr = DirectCast(System.Net.HttpWebRequest.Create(targetURI), System.Net.HttpWebRequest)

            'In the above code http://weblogs.asp.net/farazshahkhan is used as an example

            'it can be a different domain with a different filename and extension

            If (fr.GetResponse().ContentLength > 0) Then

                Dim str As New System.IO.StreamReader(fr.GetResponse().GetResponseStream())

                Response.Write(str.ReadToEnd())

                str.Close()

            End If

        Catch ex As System.Net.WebException

            Response.Write("File does not exist.")

        End Try

    End Sub

Open in new window

0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24745184
From MSDN
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx

Do not use the HttpWebRequest constructor. Use the WebRequest..::.Create method to initialize new HttpWebRequest objects. If the scheme for the Uniform Resource Identifier (URI) is http:// or https://, Create returns an HttpWebRequest object.

0
 
LVL 17

Expert Comment

by:selvol
ID: 24761011
Here is the answer. And not some plug trying to sell you something.

I only describe what I have found myself whilt using the software over the last 6 years.

Offline explorer  enterprise.  
Free 30 Day Full Featured Trial.

If you need to scrub your harvest.
OE will intergrate with "TEXTPIPE" and clean/ format the files.
NO FULL TRIAL for Textpipe.


Now OE Enterprise is very powerfull.
NOT SOME 1/2 Butted software for KIDS to get myspace profiles.
But it will do that  


#1 Info ripper/ harvester I have come across.

At first you will not see the full potential.
Don't get discuraged.
This software can do what you want. You just have to learn how to teach the software.
Enterprise can D/load Millions of URL with the push of a button.

The scripts/commands will emulate PHP like URL rewriting.
You can
Tell it to start at
http://joessite.xxx/1{:000000..999999}.php

And it will Dl-oad 1 millions pages from joessite.
Add filters like keywords, text, dir,

I can go on for a while.

Oh yea it will login too.
At Midnight and Not get Copies of the page you already have.

If you are serious about your harvest.
I suggest you get OE enterprise

This app will do more then you need ...

100,000,000 pages downloaded with it  myself...

No I don't get paid to promote this company.
http://www.metaproducts.com/mp/Offline_Explorer_Enterprise.htm
0
 

Author Comment

by:MatrixUnleashed
ID: 24762092
Thanks but i would like to do this project myself not just for completion but for the learning as well. I really feel the others comments are putting me on the right track. I successfully scraped ....
0
 

Author Comment

by:MatrixUnleashed
ID: 24762115
(cont)... my target but im reading and reading but cant understand how to login with the targetd page not an asp?
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24762363
Matrix,

Glad to hear my advice is working so far.  Here is some more info for you.  It is C# but it should give you a place to start.  I skimmed it rather then reading it fully but it looks like they are using http.webclient to log in.  Might be that you have to log in first then send the request.. any way here is the link.  Check it out and let me know what you think.

http://forums.asp.net/p/1441206/3270169.aspx
0
 
LVL 8

Expert Comment

by:lharrispv
ID: 24839376
Matrix.. how is this going?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now