4 messages in com.googlegroups.google-desktop-developerRE: Parsing the HTML received through...
FromSent OnAttachments
Rajen15 Feb 2008 04:40 
Bijoy Thangaraj15 Feb 2008 07:02 
Rodrigo Costa15 Feb 2008 07:28 
Benjamin [API Guru]15 Feb 2008 07:32 
Subject:RE: Parsing the HTML received through XMLHttpRequest object (via responseText)
From:Rodrigo Costa (cost@gmail.com)
Date:02/15/2008 07:28:19 AM
List:com.googlegroups.google-desktop-developer

Hi let me try to help.

Here follows a piece of code from one of gadgets that requests a webpage and then parse its html:

function getResultados(){ Request = new XMLHttpRequest(); try { Request.open("GET", "http://...", true); } catch (e) { Request = null; error(); return; } Request.setRequestHeader('Accept','*/*'); Request.setRequestHeader('User-Agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022)'); Request.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); Request.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); Request.setRequestHeader("Pragma", "no-cache");

Request.onreadystatechange = onGetData; try { Request.send(); } catch (e) { Request = null; erroe(); return; } }

function onGetData() { var str; var a=0; var b=0; var conc="";

if (Request.readyState != 4) return; if (Request.status != 200) { Request = null; error(); return; }

str=Request.responseText; try { a=0; b = InStr(str, "|"); conc = Mid(str, a, (b - a)); } catch (e) { Request = null; error(); return; }

Request = null; }

function Mid(str, start, len){ if (start < 0 || len < 0) return ""; var iEnd, iLen = String(str).length; if (start + len > iLen) iEnd = iLen; else iEnd = start + len; return String(str).substring(start,iEnd); }

....

thats it...i hope this will help you!

_____

From: Goog@googlegroups.com [mailto:Goog@googlegroups.com] On Behalf Of Bijoy Thangaraj Sent: sexta-feira, 15 de fevereiro de 2008 13:02 To: Goog@googlegroups.com Subject: Re: Parsing the HTML received through XMLHttpRequest object (via responseText)

Hello,

Could you be little more specific? In this case, you will be having the entire source code of the HTML in your responseText. Extracting info from it will be like extracting the info from a string that contains the source code.

On Fri, Feb 15, 2008 at 6:10 PM, Rajen <raje@gmail.com> wrote:

I've a problem. I'm trying to receive a webpage through XMLHttpRequest via responseText. I want to extract info. from it. How do I proceed?

The html file contains all the elements - like javascript, css - embedded Please help me out. Thanks.