473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scrape text from browser surface (not HTHML)

I need to do the equivalent of 'select all' and 'capture' on a browser
screen. I just want the text as it appears on-screen. Is there a simple
way to automate this?

The thing that may make it a bit awkward is that the browser windows
appear as popup-style windows, with no navigation buttons. That part
may not be so easy to automate.

Nov 16 '05 #1
5 1369
Just fire a webrequest at it. The return is an html string which you can
parse (preferrably with a regex expression) to extract what you want. I have
some code somewhere but i believe i plaigerized it from the net so you
should be able to find a lot of code to do just that. regexlib.com will help
you with the appropriate regex expression

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"_BNC" <_B**@nospam.ne t> wrote in message
news:2a******** *************** *********@4ax.c om...
I need to do the equivalent of 'select all' and 'capture' on a browser
screen. I just want the text as it appears on-screen. Is there a simple
way to automate this?

The thing that may make it a bit awkward is that the browser windows
appear as popup-style windows, with no navigation buttons. That part
may not be so easy to automate.

Nov 16 '05 #2
>>I need to do the equivalent of 'select all' and 'capture' on a browser
screen. I just want the text as it appears on-screen. Is there a simple
way to automate this?

On Fri, 19 Nov 2004 22:59:53 -0500, "Alvin Bruney [MVP]" <vapor at
steaming post office> wrote:
Just fire a webrequest at it. The return is an html string which you can
parse (preferrably with a regex expression) to extract what you want. I have
some code somewhere but i believe i plaigerized it from the net so you
should be able to find a lot of code to do just that. regexlib.com will help
you with the appropriate regex expression


That sounds like a good idea, Alvin, but I just checked regexlib.com and
came up empty. (Lots of good stuff there though, so thanks for the
pointer.)

I thought there would be a simpler way of bringing up the window and
inducing a text capture programmaticall y, just as if the user had done it.
Of course if there is an efficient regex expression, that would be great,
but it's tough to come up with efficient search keys for googling that
type of thing.

You'd think someone would have a nice C# function for turning ugly html
email into readable text. Or something equivalent.

Nov 16 '05 #3
well it's not that difficult to concoct a good regex expression to do this.
if you post a request for help in c# newsgroup, i'm sure you can get someone
like chris r to write you one. I steal stuff off of regexlib and modify it
for my devious purposes. i'm no good at writing that stuff from scratch.

i the webrequest code if you want it by the way

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"_BNC" <_B**@nospam.ne t> wrote in message
news:4k******** *************** *********@4ax.c om...
I need to do the equivalent of 'select all' and 'capture' on a browser
screen. I just want the text as it appears on-screen. Is there a
simple
way to automate this?


On Fri, 19 Nov 2004 22:59:53 -0500, "Alvin Bruney [MVP]" <vapor at
steaming post office> wrote:
Just fire a webrequest at it. The return is an html string which you can
parse (preferrably with a regex expression) to extract what you want. I
have
some code somewhere but i believe i plaigerized it from the net so you
should be able to find a lot of code to do just that. regexlib.com will
help
you with the appropriate regex expression


That sounds like a good idea, Alvin, but I just checked regexlib.com and
came up empty. (Lots of good stuff there though, so thanks for the
pointer.)

I thought there would be a simpler way of bringing up the window and
inducing a text capture programmaticall y, just as if the user had done it.
Of course if there is an efficient regex expression, that would be great,
but it's tough to come up with efficient search keys for googling that
type of thing.

You'd think someone would have a nice C# function for turning ugly html
email into readable text. Or something equivalent.

Nov 16 '05 #4

(Re extracting just visible text from HTML)

On Mon, 22 Nov 2004 22:20:26 -0500, "Alvin Bruney [MVP]" <vapor at
steaming post office> wrote:
well it's not that difficult to concoct a good regex expression to do this.
if you post a request for help in c# newsgroup, i'm sure you can get someone
like chris r to write you one. I steal stuff off of regexlib and modify it
for my devious purposes. i'm no good at writing that stuff from scratch.
I confess to xposting this to the C# group in the hope that someone would
notice it. I'm sure I've seen something like this at one time, too. But
it would involve breaking down HTML tables, translating symbols like
'nbsp' and all that. I'm sure it's been done, but it soulds like a lot of
wheel-reinventing if I have to do it myself.
i the webrequest code if you want it by the way


That would be nice! Thanks.

BNC

Nov 16 '05 #5
this is a webservice i used to scrape telephone directory information from
anywho.com. It's pretty rough code but you should get the general idea

[WebMethod]

public string PhoneLookup(str ing strNumber, ref int counter)

{

string strResult = string.Empty, searchtext = string.Empty;

try

{

// Create a new 'Uri' object with the specified string.

Uri myUri =new
Uri("http://www.anywho.com/qry/wp_rl?npa="+str Number.Substrin g(0,3) +
"&telephone ="+ strNumber.Subst ring(3,7) + "&btnsubmit.x=3 6&btnsubmit.y=9 ");

// Creates an HttpWebRequest with the specified URL.

HttpWebRequest myHttpWebReques t = (HttpWebRequest )WebRequest.Cre ate(myUri);

myHttpWebReques t.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; Q312461; .NET CLR 1.0.3705)";

HttpWebResponse res = (HttpWebRespons e)myHttpWebRequ est.GetResponse ();

StreamReader sr = new StreamReader(re s.GetResponseSt ream(),
System.Text.Enc oding.UTF8);

string pageContent = sr.ReadToEnd();

res.Close();

sr.Close();
int startpos = pageContent.Ind exOf(@"bin/amap.cgi?") + 10;

if(startpos != -1)

{

int endpost = pageContent.Ind exOf("Maps &amp; Directions");

if(endpost != -1)

searchtext = pageContent.Sub string(startpos , endpost - startpos + 17);

searchtext = searchtext.Repl ace(">Maps &amp; Direct"," ");

searchtext = searchtext.Repl ace("gi?lastnam e="," ");

searchtext = searchtext.Repl ace("firstname= ","\n");

searchtext = searchtext.Repl ace("+"," ");

searchtext = searchtext.Repl ace("="," ");

searchtext = searchtext.Repl ace("&"," ");

searchtext = searchtext.Repl ace("\\"," ");

searchtext = searchtext.Repl ace("\""," ");

searchtext = searchtext.Repl ace("city","\n" );

searchtext = searchtext.Repl ace("state","\n ");

searchtext = searchtext.Repl ace("zip","\n") ;

searchtext = searchtext.Repl ace("country"," \n");

searchtext = searchtext.Repl ace("npatelepho ne","\n");

searchtext = searchtext.Repl ace("streetaddr ess","");

strResult = searchtext;

sr.Close();

pageContent = string.Empty;

}

}

catch

{

// return "No records exist";

// count++;

return null;

}

Agent.SelectedI ndex = -1;

if(strResult.Tr im() == string.Empty)

return null;

counter++;

return strResult + "\n\n";

}
--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"_BNC" <_B**@nospam.ne t> wrote in message
news:89******** *************** *********@4ax.c om...

(Re extracting just visible text from HTML)

On Mon, 22 Nov 2004 22:20:26 -0500, "Alvin Bruney [MVP]" <vapor at
steaming post office> wrote:
well it's not that difficult to concoct a good regex expression to do
this.
if you post a request for help in c# newsgroup, i'm sure you can get
someone
like chris r to write you one. I steal stuff off of regexlib and modify it
for my devious purposes. i'm no good at writing that stuff from scratch.


I confess to xposting this to the C# group in the hope that someone would
notice it. I'm sure I've seen something like this at one time, too. But
it would involve breaking down HTML tables, translating symbols like
'nbsp' and all that. I'm sure it's been done, but it soulds like a lot of
wheel-reinventing if I have to do it myself.
i the webrequest code if you want it by the way


That would be nice! Thanks.

BNC

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2526
by: Askari | last post by:
(Help for Pygame module) Hi, How I can make a "fadeout text"(alpha at 255,254,253...0) on a surface and my surface's background must be transparatly? Note : I can do a fadeout but with a background on the surface's text but I wan't a tranparently background. Example (don't work) :
5
1651
by: crjunk | last post by:
I have a screen scrape page that allows the user to submit a url. When they hit submit, the page is returned back to them on my screen scrape page. Which computer actuall connects to the url to pull in the information -the user's computer or the webserver? Thanks, CR Junk
0
1123
by: | last post by:
I'm trying to capture the rendered text in browser control (Without the HTML). One of the methods I tried was to send keys to the browser control - copy it to the clipboard and then get the text back from the clipboard. such as following: reports1._ReportBrowser.Select(); (Browser control)
7
2158
by: Swanand Mokashi | last post by:
Hi all -- I would like to create an application(call it Application "A") that I would like to mimic exactly as a form on a foreign system (Application "F"). Application "F" is on the web (so basically I can not control it). I will have a form exactly on Application "A" as that of Application "F". Application "A" will submit to the url of...
2
3781
by: soul_chicken | last post by:
I'm working on a simple image upload project using the asp:FileUpload control. I read the file in and stick it into a clients content management system. The problem is that once I redirect back to a view page, the cached copy of the image from the content management system is being returned. Hit "F5" and everything comes back as intended. I...
3
5156
by: WFDGW2 | last post by:
I want to write or obtain C++ code that will scrape text from a dialog box within a poker client, and then record that text somewhere else. What do I do? Thanks.
1
2643
by: nbomike | last post by:
Hello. I want to scrape pages from a site that generates pages from form inputs using this web app . However, the URL of the results page (the page I want to scrape) is masked and is always the same. It looks something like this for every form input combination: http://www.scrapedsite.com/the/results/page.htm Is it even possible to scrape...
0
1136
by: Hamayun Khan | last post by:
Hi I need to create site scrape tool(job scrap tool). Each site to be scraped needs to have a different job scrape configured as each site will be different. The job scrape tool will allow required data to be selected, e.g. logo, job description, start date etc... When the job scrape is run the data is scraped to a database. the example...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7675
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
726
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.