Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
Posts: 3
Registered: ‎01-09-2011
My Device: BB Storm
My Carrier: Verizon

How to load webpage source for parsing?

Hello all, I am new to coding in this environment and am looking for a way to load a webpage source as text so I can parse the data I need. If there is a more efficient method of parsing a webpage, that may work as well. I have tried many methods so far with no success. I am attempting to use the 

QNXStageWebView to display the results of a URLLoader request at the moment, but havent had any success here either. Any suggestions or guidance would be greatly appreciated. Thanks!

 

var loader:URLLoader = new URLLoader();				
var request:URLRequest = new URLRequest("http://google.com");
loader.load(request);
var text:URLVariables = new URLVariables(loader.data);
webView.loadString(text);

 

Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to load webpage source for parsing?

I am not 100% sure what you want to do exactly but if you want to used QNXStageWebView you don't need the URLLoader anymore.

 

 

webView = new QNXStageWebView();
webView.enableCookies = true;
webView.enableJavascript = true;
webView.enableScrolling = true;
webView.addEventListener(Event.COMPLETE, loadWebView);
webView.loadURL(url);

private function loadWebView(event:Event):void{
	webView.autoFit = true;
	webView.stage = stage;
}

 You can find an example usage in the RSS Reader sample.

 

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
New Developer
Posts: 3
Registered: ‎01-09-2011
My Device: BB Storm
My Carrier: Verizon

Re: How to load webpage source for parsing?

zezke, thanks for the reply. I am using the URLLoader to get the HTML. I have now figured out how to load the html, but am still working on how to parse the data (im a Visual Basic guy). The webview is used to display a webpage once the user has used my apps menu to navigate to the desired page.

Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: How to load webpage source for parsing?

I am certainly not a specialist in this area, but I remember reading a topic here saying that it was impossible to get the data loaded from a QNXStageWebView component or to use the data of an URLLoader for the QNXStageWebView component.

 

See these topics:

 

Reading HTML using QNXStageWebView

 

Getting HTML from QNXStageWebView without URLLoader

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: How to load webpage source for parsing?

[ Edited ]

Don't pull it in as a regular string, pull it in as XML so it keeps the structure (or load it as a String and cast it to XML). From there, you can search the nodes with E4X notation.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: How to load webpage source for parsing?

I was trying to do this too.  Currently, there is no way to get the raw contents of the QNX web view.  If you really need it, you can get the URL and re-get the data via URLLoader.  For me, I am waiting to get it directly from the control in a "future" release.

Regular Contributor
Posts: 73
Registered: ‎12-09-2010
My Device: Blackberry Curve 8530
My Carrier: Virgin Mobile USA

Re: How to load webpage source for parsing?

[ Edited ]

After you load it in use the string.split method to manipulate the data you want. Ex:

 

 

var CSVURL:URLRequest = new URLRequest;
CSVURL.url = "http://path/to/url";
CSVURL.useCache = false;
var CSV:URLLoader = new URLLoader;
CSV.load(CSVURL);				CSV.addEventListener(Event.COMPLETE,function(event:Event):void {
	var csvsrc:String = CSV.data.toString();
	var rows:Array = csvsrc.split("\n"); //array with elements=each line
	rows.splice(0,8); //get rid of rows we might not want (optional)
	for each (info in rows) {
		var infoArr:Array = info.split(","); //array of CSV values
		trace ( infoArr[0] ); //or whatever you want to do
	}
}

 

 

 

Anthony
http://www.anthonyquarella.com
Accepted Apps: UpToDateTV